A] Identify the yetzer hara's presence. The Ba'al HaTanya teaches that when caught in the snare of temptation, one should verbally insult the yetzer hara that is attacking him. He should say, "You are evil, wicked, revolting, disgusting, and appalling. You are trying to prevent my eyes from seeing that nothing truly exists beside for Hashem" (Likutei Amarim, chapter 29). This accomplishes a few things. First, it is a distraction, an interruption of the growing passion. Second, it prevents your identity from merging with that of the yetzer hara. You are not him, and he is not you. You do not truly want to act out - it is only his voice that is speaking within you, trying to convince you and entice you into falling for his trap. Thirdly, it reminds you of the yetzer hara's evil intentions, helping unmask the feelings of pleasure to glimpse the spirit of Gehinnom hovering within (see above, letter E).
B] Think about the desire in a pragmatic way. The desire for physical pleasure is one of emotional passion. Logic plays little role in this particular human drive. Thus, once cool logic is entered into the equation, we find that our passions are more controllable. The Piacezner Rebbe gives an analogy for how this might be done. He says that if a person thinks about a childhood friend who he loves, the trait of Ahavah becomes revealed within him. He thinks to himself, "Oh, how I love this friend so dearly. Perhaps I will buy him a gift to express my friendship." He then begins to think about what gift he will buy for his beloved friend, all the while stoking the fire of his love. However, if he begins think about their relationship in a practical way, he will find it difficult to grow passionate. Thinking thoughts such as "Do I really love this friend? If so, why? What exactly do I like about him? " etc., will weaken his emotional passion. It is the same thing with desires. If we think not around them, but within them, they will become less appealing and much of the passion will cease (See Hachsharas HaAvreichim, chapter 9).
C] Hold onto an item of holiness. Many people have told me that this works for them. When you find yourself unable to hold off the yetzer hara's seductions, hold onto a davar shebik'dusha such as tzitzis, tefillin, or a sefer - preferably a sefer with which you are connected. It will be difficult for one to douse himself in impurity when he is lovingly hugging a pair of tefillin (see Tziddkas Hatzaddik 55 regarding tzitzis).
D] Go daven or do Hisbodedus: Many times, we feel stuck between a rock and a hard place. If we act out, we are miserable. But if we don't, we are also miserable! As much as we work to fend it off, this human need continues to roil within, affecting our mood, our ability to focus, and our ultimate happiness! Is there is a way to channel this passion in a way that is not damaging?
Rebbe Nachman or Breslov says that indeed there is. He suggests that one should go and either daven (if he has that opportunity) or perform Hisbodedus and talk straight to Hashem, in his own words. In doing so, he is able to release all the pent up passion and fire into his tefillah, expressing his emotions in a spiritually healthy manner (See Likutei Moharan Tinyana, 49).
Other ways of releasing this passion are: giving tzeddakah, (See Likutei Moharan 264 and Tzidkas Hatzaddik 125); teaching people Torah; and giving them good advice (See Likutei Moharan 7:3).
E] Say Krias Shema. Simple as it sounds- but with emotion and passion (Likutei Moharan 36:3).
Always remember – No matter what happens, there is no despair in the world! One must be a tremendous "akshan" in avodas Hashem, never allowing himself despair. Get right back up and continue the fight!
Hatzlacha Rabbah!! Chazak V’Ematz!!