Othello starts as an apparent domestic comedy - a couple marrying despite the intentions of the bride's parents, a hopeless young suitor to said woman, and the dock/drinking scenes in Act 2 are all staples of comedy.
Twelfth Night does this, too: Malvolio's treatment transforms from simple humiliation to something far less easy-going, as Feste takes an increasingly sadistic pleasure in his imprisonment (and 'treatments') as a supposed 'madman'. Malvolio ends the play planning his revenge on his peers.
Macbeth, Act II: Scene III Starts off with an amusingly drunk porter hamming it up while Macduff and Lennox knock to be let in, and ends with Macduff finding King Duncan's dead body, Lady Macbeth passing out "from shock," and the Crown Prince and his brother deciding to flee the country out of fear for their lives.
Hamlet can be like this. Interspersed between the dark, angsty, and sometimes violent scenes are scenes that, given the right actor and director, can be utterly hilarious. Act II, scene i, Act III, scene iii and Act IV, scenes ii and iii see Hamlet gleefully and cleverly messing with the minds of, respectively, Polonius, Rosencrantz and Guildenstern (twice), and Claudius. One of these takes place immediately after Hamlet kills Polonius, another not long after Old Hamlet appears to tell Hamlet of his murder. The second half of the play mostly settles down to dark tragedy (with a break for the comic Gravediggers), but the first half can epitomize this trope.
Romeo and Juliet actually starts off pretty light, despite the feud between the Montagues and the Capulets and the brief mention in the introduction about 'young lovers did take their life'. But then the previously comic Mercutio is mortally wounded, and dies cursing the two families, and the play turns into a tragedy. Mercutio's death scene itself is a narrower example of this trope: His fight with Tybalt initially appears to be an inconsequential skirmish, with both duelers walking away. The other characters on stage even berate Mercutio for his overdramatic (as ever) reaction to a seemingly minor injury. Half a minute later, the tragedy's Breakout Character is dead.
The best example of this is probably Loves Labours Lost: In the last act of a hilarious geeky rom-com, where some amateur actors are putting on a play and doing it badly and getting made fun of by the audience of couples, a minor lord bursts in to say that one of the women's father has died, which means that she has to leave for a year of mourning and they can't get married.
The Comedy of Errors goes in the other direction: "Proceed, Solinus, to procure my fall / And by the doom of death end woes and all" are the first two lines of Shakespeare's most hilarious comedy.
Much Ado About Nothing — Benedick: "Come, bid me do anything for thee." Beatrice: "Kill Claudio." It makes a little more sense if you read between the lines—according to Beatrice, she and Benedick had a thing before he dumped/cheated on/mistreated her, so she's mistrustful this time around—but the wrong delivery can cause this (and some nervous laughter) in an audience.
A few whiplashes in a row in Henry V. It starts with the "Once more unto the breach" rah-rah England speech, where Henry exhorts his men to take the town of Harfleur, "on, on you noblest English!" Then, after a goofy comic relief scene, Henry threatens the governor of Harfleur (and in some productions the citizens huddled around him) with rather graphic depictions of rape, pillage and murder if they don't surrender, "your naked infants spitted upon pikes!" The next scene is Princess Katherine flitting about with her maid, learning important English words like "elbow." That entire scene is a set-up for a dirty pun. Whiplash indeed.
The Merchant of Venice starts out dark, then turns into a romantic comedy, then steadily becomes darker with frequent comic interludes, then becomes really dark, then appears to wrap up happily, then darkens a bit again, then finally ends - ostensibly happily if you're willing to disregard the Unfortunate Implications, which most modern adaptations do not. In general, it's labeled a comedy.
The radio play All Is Calm, being about the Christmas Truce of 1914 during World War One, feels like nothing but this trope. It goes from some painful parts to some hilarious parts at breakneck speed and right back 'round again. High points include a tearjerker Christmas radio broadcast that's propaganda, supposedly a singalong from the soldiers in the trenches telling their family that they're all just glad to be there doing their noble duty, being drowned out by a hilarious Last-Second Word SwapBawdy Song, and a scandalised-sounding German officer's account of playing a game of football against Scottish soldiers and discovering exactly what was being worn under their kilts being read in much too close proximity to another reader talking about everyone heading off into No-Man's-Land to bury their dead friends from back in November. The worst part of it is, all the material is real.
In Into the Woods, the Witch's line played for comedic effect: "BANG! FLASH! THE LIGHTNING CRASHED AND well that's another story, never mind, anyways..."
In The King and I, the King becomes closer than ever to Anna when he learns to dance with her. He is eagerly leading an encore of "Shall We Dance?" when Kralahome bursts in and announces the arrest of Tuptim. Anna's sympathies obviously lie with the fugitive, and so the King is "now miles away from her" (according to the stage direction). The confrontation that follows is the most serious part of the play.
The Vagina Monologues consists of, well, a series of monologues about vaginas. They range in mood from "My Angry Vagina," a humorous rant about tampons and OB/GYN tools, to "My Vagina Was My Village" and "Say It," which are about the experiences of women in serial rape camps, and boldly straddle the line between Tear Jerker and Nightmare Fuel. Now imagine if your local production decided to arrange the monologues so that "My Angry Vagina" was between the other two...
"My Vagina was My Village" is Mood Whiplash within the monologue. The speaker switches between excitement and wonder to terror.
The Wedding Singer musical goes from "A Note From Linda" (sad), to "Pop" (perky) and back to "Somebody Kill Me" (pretty self-explanatory).
Too Much Light Makes The Baby Go Blind, a Chicago-area production performed for nearly 20 years by The Neo-Futurists, consists of up to 30 varying plays performed in no more than 60 minutes. Because all the plays are independent, the mood can jump immediately from silly to nearly pornographic to euro avant-guarde to darkly depressing without warning. The plays included are constantly changed as well and the order is random, so even repeat audiences will get whiplash from time to time.
Used and lampshaded by Gad Elmaleh in his show "The other, it's me". He says to the audience that this is a special night for him because his mother is here and then he confess that actually no, she's not and then joke about the audience reaction.
The final act of Puccini's opera La Bohème has a very light, funny scene of the four Bohemians goofing off together. It's interrupted mid-phrase by the arrival of Musetta and the dying Mimì, putting the opera quickly back on the path to its Tear Jerker ending.
Fame does it more gradually than most, more like a Mood U-Turn than a Whiplash, but once you notice it, it's downright bipolar. For example: the third song is about the comic relief character not being able to keep "it down" whenever he sees a certain girl; the third-to-last song is about that same girl dying of a cocaine overdose after having her chance at dancing fame utterly crushed.
In Iolanthe, after nearly two hours of silliness, the title character suddenly delivers an incredibly intense, moving and completely non-comic song by way of appeal to the Lord Chancellor - and to top that, when it doesn't work she prepares to sacrifice her life, something often Played for Laughs in G&S but here played absolutely straight. (Gilbert wrote it that way to give the comic actress playing Iolanthe a chance to show she could be serious as well.) And then the whole thing is resolved by an utterly daft ending.
The ten-minute finale of The Yeomen of the Guard lashes back and forth. The women's chorus happily heralds the bride, who sings that this is the happiest day of her life. Then her supposedly dead husband arrives to claim her. She begs him to relent; he refuses. Then it turns out he was just playing a joke on her, and everyone rejoices. Then the man she scorned enters in despair, delivering the only Downer Ending in G&S.
Hair is, at first, a fairly lighthearted musical. Then the second act happens. Claude goes on a horrifying bad trip then, despite all the attempts of the tribe to save him, is sent off to fight in Vietnam and promptly killed. Then he starts singing The Flesh Failures/Let the Sunshine in and the audience is reduced to tears. Total Downer Ending.
The second act of Ragtime is rather tense, with Sarah dead and Coalhouse (and Younger Brother) planning violent revenge. Things are getting pretty strained for the family too... so Father decides to take the Little Boy to a baseball game. The wholly comedic number "What A Game!" (wherein Father talks about what a noble and genteel game baseball is, while continually interrupted by the spitting, swearing, and general rudeness of the other spectators) ensues. Then it goes right back to the tension. (The scene was a little out of place in the book as well, but wasn't quite so much Played for Laughs there.)
The song Contact in RENT whips first from an uncomfortably frank look at the sex lives of the main characters (harder faster wetter) to a funny scene of unsatisfying sexual experiences all around as they stumble through trying to maintain safe sex practices without losing their rhythm and fail ("I think I missed... don't get pissed"/ "It was bad for me, was it bad for you?"). Then, when it has the audience giggling, it wrenches back around and gut-punches you with Angel's death.
And, as it's a modern retelling of La Bohème above, it has the scene above. Mark, Roger and Collins are singing in the apartment about how they'll get to Santa Fe yet... Then a dark reprise of I Should Tell You kicks in, we hear Maureen cry for help, and instinctively, you're thinking "Oh SHIT."
Anything by Martin McDonagh; "The Lieutenant of Inishmore" switches from two Irish yokels dismembering corpses at gunpoint to the same two finishing an earlier argument over whether or not a cat will eat corn flakes.
The concluding sextet from Mozart's Don Giovanni is often omitted in production, since its lightheartedness clashes with the intensely melodramatic preceding scene in which Don Giovanni is Dragged Off to Hell.
Cyrano de Bergerac: Given this play is a blend between Farce and Tragedy, there first three acts are more of a comedy with some dramatic elements, and the two last acts are more of a drama with comedic elements, but in all acts the contrasting elements resonate against each other.
Which picks up right where Act One left off, with Christine and Raoul singing "All I Ask of You" and generally being sweet and adorable young lovers together...followed by the revelation that the Phantom overheard the entire thing and is heartbroken. He doesn't take it well.
In the second act of Spring Awakening, the show goes from the heartbreaking scenes of Moritz's suicide and funeral to the fast-paced song, "Totally F***ed", basically going from a scene of depression and mourning to one big, energetic "eff you".
The show is a big fan of this trope. For instance, Melchior is introduced with his signature song "All That's Known", a yearning, hopeful and elegant declaration from Melchior about how he is (of course) terribly sick of all these adults telling him to trust what's written and be quiet and subservient. The next song that immediately follows, from his sexually-frustrated, nervous wreck of a friend Moritz, is a song, ultimately, about how horny they all are. Melchior even joins in eventually, which makes it incredibly awesome and eye-opening about the overall themes of the musical.
Snoopy! the Musical has the heartwarming songPoor Sweet Baby, in which Peppermint Patty sings to Charlie Brown the way he wishes that a girl would sing to him. When the song is over, we get this:
Peppermint Patty: Like that, Chuck?
Charlie Brown: Just like that, Patty.
Peppermint Patty: Forget it. It'll never happen.
The strip the song was based on obviously didn't have a song at all, just Charlie wanting to be called "poor sweet baby", so the punchline was a lot less abrupt.
The Wicked musical has quite a bit of this. In-between the depression, even after Cerebus Syndrome kicks in, you have light hearted comedy.
Miss Saigon has a beautifully subverted version, as we, the knowing audience, already know what's going to happen and are already saddened, whereas Kim, the title character, is blissfully ignorant. She's preparing to reunite with her lost love Chris, dressing in wedding gown, joyfully singing. She rushes to his hotel room. . .only to be greeted by Ellen, Chris' wife. The devastation evident in Kim's entire body is staggering.
Elisabeth features a very tender, moving love song between the titular heroine and her fiance, "Nichts ist schwer", that is abruptly and immediately followed by Ominous Pipe Organ and a choral piece predicting the singers' doom... at Elisabeth's wedding.
Fiddler on the Roof has a sombre wedding ceremony, during which the older characters sing "Sunrise, Sunset", a melancholic rumination on how fast time flies. Then, there's the joyous, celebratory bottle dance - but the celebration is broken up by the Russians riding into the village, breaking up the party.
The touring 1990s-era revival of The Sound of Music was mostly cute singing kids and nuns, while occasionally adults sitting around a mansion spoke about vaguely troubling developments. Then it was time for the talent contest to take place—and three Nazi banners abruptly dropped down from the ceiling. Cue audience gasp and Mood Whiplash as everyone suddenly remembered just what was on the horizon.
The 25th Annual Putnam County Spelling Bee: "The I Love You Song" is a massive mood whiplash, as the play is almost entirely a raunchy comedy up until this point and there's utterly no warning that the upcoming song is going to be leading to more than a few tears until it finally starts.
Godspell reimagines the New Testament as a quirky, lighthearted comedy about the formation of a community, rife with Slapstick and vaudeville routines. Things take a sudden turn in Act 2 when Jesus encounters the Pharisees in "Alas For You". From there, Jesus is betrayed and crucified just as in the source material, and his disciples can only watch helplessly as the man who brought happiness and meaning into their lives bleeds to death in front of them.
Claudio Monteverdi's landmark opera L'Orfeo features a pretty good example early in Act II. Everyone's preparing for Orfeo's wedding to Euridice, and most of the opera up to now has been one long celebration of the 'happy and fortunate day'... and then suddenly a Messenger arrives and announces that Euridice has just died. Monteverdi went out of his way to ensure that the music drove home the sudden change of mood; as soon as the Messenger arrives the vocal timbre is shockingly different (she's a mezzo soprano, the last voice heard was a tenor), as is the instrumental accompaniment (from harpsichord to theorbo and organ), the harmony (the last section ended on a C major chord and she starts on A major), even the style of the music (from lyrical song to harsh, declamatory recitative). Even 400 years after the opera's premier it's still a pretty shocking moment.