In punctuation, use commas before direct speech introduced with phrases such as "he said".
Punctuating direct speech is a technical skill. If you begin your sentence by introducing the direct speech, you will need a comma first. Here is an example which has been correctly punctuated:
She said, "I am not at all happy about having to climb this staircase in the dark."
The comma separates the introduction from the speech even when using a longer, more complex, phrase, as here:
She said, grumbling under her breath, "I am not at all happy about having to climb this staircase in the dark."
You will notice that the direct speech itself also ends in punctuation. Always place some form of punctuation before the closing speech marks. The examples above end in full stops. If we reverse the sentence, we still need some form of punctuation, as here:
"I am not at all happy about having to climb this staircase in the dark," she said.
Notice that "she" begins with a small letter because the sentence is not yet finished. This is true even if the direct speech is punctuated with a question mark or exclamation mark:
"I am not at all happy about having to climb this staircase in the dark!" she exclaimed loudly.
"Are you happy about climbing this staircase in the dark?" she asked.
So remember: a comma always separates the direct speech from an introductory phrase such as "he said", some form of punctuation is always necessary before the closing punctuation marks and, when continuing a sentence past the direct speech, do not use capital letters for phrases such as "she said", even if you've used a question mark or exclamation mark. Easy, right?
Test yourself with this quiz on punctuating direct speech.