I put on my cheeriest pop music, strip down to my underwear, and dance.
That never fails. Really.
If it's more pervasive, I'd suggest doing something you normally wouldn't do, like taking a ballroom dancing class or whatever.

Get outta the rut, so to speak.
And masturbation never hurt anyone.