This is an area I know a lot of people have difficulties with. I’ve seen a lot of mistakes made where writers are not sure where to put a comma or full stop. Here is an example of the correct way to use them:
“I meet a wizard today,” Sam announced.
“Sam, you’re nuts!” Peter replied. “Wizards don’t exist.”
“They do,” Sam insisted, “because I meet one today.”
With the first piece of dialogue, some people make the mistake of placing a full stop after the word “today” (ie “I meet a wizard today.” Sam announced.), which is wrong. The dialogue tag is part of the overall sentence.
In the second set there are two complete sentences so a full stop is placed at the end of the dialogue tag. Also, when using a name or another word like – hey, oh, well, boy – you should always place a comma after that word. A good way to test this out is to read the sentence without the word, if it makes sense without it use a comma – if it doesn’t make sense then a comma is not required.
With the last line, the dialogue tag is placed in the middle of a complete sentence so you should place a comma after the first part – the word “do” in this case – and at the end of the dialogue tag as shown.
Oh, one more thing, ALWAYS start a new line for each person who speaks. ALWAYS!