You hyperventilate right before the take, the same technique as for swimming underwater [not highly recommended underwater, but in air, of course, you can change your mind and breathe again at any time]. Also, bear in mind, you're "dead" so not doing much in the way of running around getting out of breath.
Zombies would be a whole different question and answer ;)
The idea is that you reduce the carbon dioxide levels and slightly increase oxygen levels in your lungs, reducing the urgency to breathe again quite so quickly.
It's also helpful if you're in place a good few minutes before the take, so you have time to relax and not have just rushed to set at the last minute, already breathless.
So, as you hear the 1st AD prepping for the take you breathe big and deep for 5 - 10 seconds. Each 1st AD uses a slightly different but predictable series of commands to the crew...
"Quiet, please. For a take"
"Roll please" [to this a dozen others yell "Turning" right across the set]
Then sound says "speed"; you hear clappers announcing the take; camera ops say "set" [which is always the final signal that everything is ready to go].
"We're turning... and.. "
... you over-breathe until you hear the "and" right before action - then breathe right out.
Corpses do not breathe.
They do not have inflated chests, so you cannot start with an in-breath, you must have breathed right out.
Corpses that breathe get shouted at ;)
"Cut. Reset. We can see the corpse breathing."
Not a good way to use the studio's money.
Corpses that don't breathe on camera get more work than those who do.
In the rehearsal takes you keep your eyes open and watch the cameras, so you know [and can either count in your head or work from any dialogue you can hear] when you need to be mostl still. At other times you can, of course, breathe shallowly until you know you're in frame. If you're not sure and you think it might be significant - ask. Someone can count you through a rehearsal.
The other thing to note, from an audience perspective, is that long 3-minute scene where you were amazed at the corpse not breathing for the whole thing probably took a day to shoot. He probably had to not breathe for no more than 30 seconds in any individual take.
 The "and" before Action is often significant and highly emphasised. Background [supporting artists/extras/vehicles etc] often need to be in motion before the action actually starts to keep a fluid look to the scene. "Go on and" is a common phrase.
Just a late note on
In some movies you can tell that the picture is paused when it is on the dead character.
I don't think I've ever seen this done [I'm not saying it's never ever been done, but I've never spotted it]. The eye is really very sensitive to movement and a total still image would be quite jarring and noticeable.
After comments and other answers...
Note: it's considerably harder to hold your breath whilst breathed out, as opposed to in. You don't have the lungful of oxygen in reserve and the rise in carbon dioxide is more concentrated.
If you didn't know already, the "urgency to breathe" reflex is not triggered by lack of oxygen, but by increase in carbon dioxide concentration.