Do something else.
Temptation cannot occur when one is occupied; therefore, step out of the present scene as dramatically as you can.
Call a friend, go to the movies, get involved with someone else’s problems. Calling the police or throwing a pie at someone may be a bit much, but some activity that breaks the pattern of your present situation is called for.
It’s amazing how few people are tempted to sin during a fire alarm.
The following quote comes from Fr. Benedict Groeschel in his book The Courage to Be Chaste. Click here to read my review of it.