on Just Publishing Advice:
There is one basic rule for dialogue punctuation.
“Keep your punctuation inside the quotation marks!”
There are a few more technical dialogue punctuation rules.
But when you develop the habit of enclosing your punctuation, you will be right 95% of the time.
7 Punctuation rules for dialogue