The one who has a septic wound should do whatever it takes to remove the poison and heal the wound, with antidotes and ointments. This may be achieved in several ways, such as:
Getting married, because the Prophet (peace and blessings of Allaah be upon him) said: “If one of you sees the charms of a woman, let him come to his wife, for she has the same as (the other woman).” This will reduce desire and weaken the infatuation.
Persisting in offering the five daily prayers, saying du’aa’ and beseeching Allaah during the period before dawn. His prayer should be offered with proper presence of mind and focus. He should say a lot of du’aa’ such as “Yaa muqallib al-quloob thabbit qalbi ala deenak (O Controller of the hearts, make my heart adhere firmly to Your religion)” and “Yaa musarrif al-quloob, sarrif qalbi ila ta’aatika wa ta’aati rasoolika (O Director of the hearts, direct my heart to obey You and Your Messenger).” If he persists in du’aa’ and beseeching Allaah, He will direct his heart away from that, as Allaah says (interpretation of the meaning): “Thus it was, that We might turn away from him evil and illegal sexual intercourse. Surely, he was one of Our chosen, (guided) slaves” [Yoosuf 12:24].
End quote from al-Fataawa al-Kubra (3/77) by Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him).
Keeping away from places where there are adorned women, and TV channels and so on that show images that may affect and weaken the heart.