Let’s take this from the top. Generally, the words characters speak go inside quotation marks. That’s called dialogue. The narrative that signifies who does the speaking is called the tag.
There are different ways you can tag dialogue. You can simply attribute the speaker:
“I have to go,” he said.
“I have to go,” Gordon said.
“I have to go,” the woman cried.
Or you can include thought or action:
“That stinks,” she said, holding her nose.
“That stinks.” She held her nose.
“That stinks.” She couldn’t wait to leave.
With dialogue, punctuation generally goes inside the quotation mark:
“I adore pecan pie,” she said.
The exception is when the tag comes before the dialogue:
She said, “I adore pecan pie.”
Notice, though, the period at the end of the dialogue still goes inside the quotation marks.
Tags don’t have to just come before or after dialogue. They can be plopped right in the middle too, as long as you’ve got the right punctuation in play. If the tag separates two sentences or ideas it would look like this:
“I adore pecan pie,” she said. “What about you?”
If the tag is placed in the middle of one complete sentence of dialogue, it would look like this:
“I adore pecan pie,” she said, “when it’s warmed in the oven.”
Punctuating dialogue does demand close attention, but once you get in the habit, those marks will fall in the right place with little thought.