Memorise this Gurbani Pangti and recite it loud when such thoughts occur:
ਨਿਮਖ ਕਾਮ ਸੁਆਦ ਕਾਰਣਿ ਕੋਟਿ ਦਿਨਸ ਦੁਖੁ ਪਾਵਹਿ ॥
For a moment of sexual pleasure, you shall suffer in pain for millions of days.
ਘਰੀ ਮੁਹਤ ਰੰਗ ਮਾਣਹਿ ਫਿਰਿ ਬਹੁਰਿ ਬਹੁਰਿ ਪਛੁਤਾਵਹਿ ॥੧॥
For an instant, you may savour pleasure, but afterwards, you shall regret it, again and again. ||1||