To begin with, your sexual attraction toward women has been stamped into your heart by God, not by the devil. There is nothing sinful about being sexually attracted to a girl. It is normal and healthy. Do not feel guilty about sexual attraction because it is not the same thing as lust. Just because you have strong desires, this does not mean that you are impure.
Lust is a different matter because it is a conscious act of the will to allow your mind to imagine illicit sexual acts. Lust treats the person as an object—a thing to be used for your pleasure. Therefore it is a distortion of love, and it will never satisfy. Illicit sexual acts such as premarital sex—or deliberately imagining premarital sex—are always incomplete.
Jesus wants us to have the fullness of love and not sell ourselves short with lust. So he warned us that whoever looks lustfully at a woman has already committed adultery with her in his heart (Matt. 5:28). By saying this, Jesus is not condemning us but is calling us. Work as Saint Paul did to “take every thought captive to obey Christ” (2 Cor. 10:5).
In regard to what to do with tempting thoughts, I recommend what I have recommended elsewhere: If you have impure magazines, videos, and music, get rid of them. Become a man of prayer. Be patient with yourself. Impure thoughts are bound to come. Take it one day at a time, one minute at a time, and one thought at a time. Do not get overwhelmed. Purity of heart does not mean that you are never tempted and that you cease to be sexually attracted to others. Some people even think that they are pure just because they do not have strong desires or because they never had the opportunity to do something impure with a girl. This is not purity. To be pure requires an act of the will to love, not the absence of sexual desire.
One way to grow in purity is to be grateful for the beauty of women. Lust and true gratitude cannot coexist. So when you see an attractive woman, instead of thinking of her as a mere temptation, give thanks to God for making women so amazing. You could pray the words of Psalm 84, “How lovely is your dwelling place, Lord Mighty God!” How fitting, since every woman is a temple of the Holy Spirit, a dwelling place of God.
All beauty comes from God. Therefore, allow the beauty of every woman to remind you of the infinitely greater beauty that awaits you in heaven if you persevere in faith. By doing this you turn your heart toward God when you otherwise may be tempted to turn away from him. Now, I’m not recommending you gawk at a woman and offer a twenty minute prayer of thanksgiving, or you seek out gorgeous women for the sake of having more reasons to be thankful. Rather, be grateful for a woman’s beauty when you notice it, and then move on.
All that God asks is that you be faithful to him as he reveals himself to you in the present moment. He loves you and will give you the grace you need to maintain your purity. As you grow in control over your mind, you will have greater control over your body. “No temptation has overtaken you that is not common to man. God is faithful, and he will not let you be tempted beyond your strength, but with the temptation will also provide the way of escape, that you may be able to endure it” (1 Cor. 10:13).