The problem with a mood whiplash is: one of your characters just experienced something tragic, your readers are with the character in that tragic moment. If you want the readers to experience that tragedy, you've got to give them time to process, to experience. When you jump to a comic scene instead, you're telling the reader "don't bother experiencing the tragedy, it isn't important. Let's move on". You're treating the story like it doesn't matter, you're subverting yourself.
Proceeding from this understanding, it follows that the natural progression from a tragic scene is acknowledging the tragedy, mourning, and only then moving on. That would be the natural progression for the characters, right? That's how humans experience and process tragedies. An example: in The Lord of the Rings, after Gandalf falls, the other members of the Fellowship mourn him. Amid the wonder of Lothlorien, they each acknowledge their grief. Similarly, when Boromir is killed, the others take the time for a funeral.
There are alternatives. You might, for example, jump from a tragedy to a happy scene with people who do not yet know of the tragedy, and would very much care. In that case, the scene would be overshadowed by the dramatic irony. The mismatch between the readers' knowledge and the characters' ignorance would create tension. It's a situation that you can't sustain for long, but you can break it for additional drama. A classic example would be guys joking about their friend always being late, when the readers know said friend is dead.
A scene can be both tragic and comic. Mercutio's "look for me tomorrow and you will find me a grave man" in Romeo and Juliet is a classic example: the scene starts out comic, and then, suddenly, Mercutio is killed, and it's not comic any more. There's this moment when one hasn't quite processed yet that tragedy has struck. Shakespeare evokes that with Mercutio's jokes, and Romeo not realising that his friend has been dealt a mortal wound. Like Looney Toons, Romeo has gone off a cliff and continues running, only there's no longer ground under him. It's a shock that strikes the audience and the character together. You could say that this scene derives its strength from the mood whiplash - the whiplash is realistic, what the characters would experience, what's supposed to happen. It doesn't undermine the story - it is the story.
A final example is the very last scene of La Vita e Bella.
The main character's father has just been shot off-screen, and then there's the tank.
There is great comedy in that scene - it's a punchline to a joke that you didn't expect would happen. But it works not because of the comedy, but because it is also a release of all the tension that's been sustained throughout the film: the Allies have come to liberate the concentration camp. The audience is allowed a sigh of relief. There is great tragedy, but laughter is permitted again.
While transitioning from tragedy to comedy is nigh impossible, transitioning from tragedy to joy is common enough: For example, the film Operation Thunderbolt transitions from the death of Yoni Netanyahu, to the liberated hostages landing in Israel and being welcomed by their families. In such transitions, the joy is coloured by the price paid for it, and the tragedy is made meaningful because of what it won.
Which all boils down to this: consider what emotions you wish to evoke with the story you're trying to tell. Proceed from this to structure your scenes in such a way that they support what you're trying to evoke, not undermine it. "What you're trying to evoke" is a meta question about your writing. It might be that you won't be asking it when writing your first draft, when you're still discovering what your story is all about. But it is a question you must ask at some stage of the writing process.