Before we get started, the answer to your question actually depends on where you live.
More specifically, THE FOLLOWING RULES ARE FOR AMERICAN ENGLISH, which is very strict when it comes to putting commas and periods in and around quotation marks. British English uses rules that allow the writer to determine whether the period or comma belong with the quotation or are part of the larger sentence. (See below.)
If you want to be “safe," go with the rules for American English: if nothing else, it’s consistent and "predictable." (See what we did with the punctuations after "safe" and "predictable"?)
Cheers.
This is particularly vexing so this post us quite useful.