It depends on the context. If you think it is clear to a reader who is speaking, don't use a tag.
If you think it will not be clear who is speaking, put the tag first, to orient the reader, so the speech is not disembodied until the end.
Also put the tag first if you will use something besides "said":
Richard screamed, "Don't bother me!"
Your first example is wrong, if a tag follows, the statement ends in a comma.
"Don't bother me," he said.
The use of an end tag is typically a device to avoid awkwardness in continuing in the same paragraph with additional exposition.
"Don't bother me," he said, and rolled over in the bed, turning his back on her.
But it can be avoided, and save words, if it is clear.
"Don't bother me." He rolled over in the bed, turning his back on her.
Personally I find the second version stronger, and seldom use tags following the speech.
You can also avoid tags and enhance the dialogue by using action cues.
Mary hesitated, then picked up Richard's two hundreds and handed them to Bill. "Alright. Let's do it."
Mark frowned, then turned back to the mirror and continued shaving. "Really? I must have driven right past that."
These increase the visuals, tell the reader who is talking, and avoid "said" tags completely. When you read them, the visual of the action (and what is going on in the scene) also clues the reader into the tones, so you can avoid characterizing the tone of the speech, like "Mary said resignedly" or "Mark mused" or whatever.