* "I'm so hungry," she said, "I could eat a horse." (The comma separates the quoted statement from the rest of the sentence.)
* "We're going to the park," he explained, "to play basketball." (The comma separates the explanatory phrase from the quoted statement.)
* She whispered, "I love you," and then kissed him. (The comma separates the introductory phrase from the quoted statement.)
The key is that the comma should be placed outside the closing quotation mark if it is part of the overall sentence structure, not part of the quoted material itself.