About using “said” in dialogue

Solution 1:

Either form you gave is fine. Moreover, either of these forms can also be used in the middle of a quote, too:

"I am going to the bank," said John, "before it closes."
"I am going to the bank," John said, "to deposit some cash."

In writing, you probably want to avoid using the same form, in the same relative location, over an extended dialogue. That would get wearisome:

"I am going to the bank before it closes," said John.
"Maybe I should come with you," said Mark.
"Fine with me. There's plenty of room," said John.
"We'd better hurry. I think the bank closes in 15 minutes," said Mark.
"Well, then, let's not just stand here talking," said John.

Instead, something more like:

"I am going to the bank before it closes," said John.
"Maybe I should come with you," Mark replied.
"Fine with me. There's plenty of room."

You get the idea. (If I delve into it any more deeply than that, this'll get migrated to Writers.SE.)

Solution 2:

It’s customary to use inversion only if the attribution follows the quote, not if it precedes it. So:

  • John said, “I am going to the bank.”
  • “I am going to the bank,” said John.