Or as TV Tropes would have it: Mood Whiplash
. Fruits Basket episode 9 is the almost perfect textbook example of the trope.
It starts with one character playing hilariously funny practical jokes on his poor long suffering editor...for about half the episode. It ends with [spoiler] by way of [spoiler] less than ten minutes later. I'll give you a guess though: neither of those are comedy.