St. Francis de Sales recommends the following:
Fly rather than Fight
Be exceedingly quick in turning aside from the slightest thing leading to impurity, for it is an evil which approves stealthily, and in which the very smallest beginnings are apt to grow rapidly. It is always easier to fly from such evils than to cure them.
Human bodies are like glasses, which cannot come into collision without risk of breaking; or to fruits, which however fresh and ripe, are damaged by pressure. Never permit any one to take any manner of foolish liberty with you, since, although there may be no evil intention, the perfectness of purity is injured.
Purity has its source in the heart, but it is in the body that its material results take shape and therefore it may be forfeited both by the exterior sense and by the thoughts and desires of the heart.
All lack of modesty in seeing, hearing, speaking, smelling or touching is impurity, especially when t impurity and uncleanliness, or foolish and unseemly talking, are not to be “so much as named” among Christians. St. Paul says without hesitation that the bee not only shuns all carrion, but abhors and flies far from the faintest smell proceeding therefrom.
Blemishes to Purity
Remember that there are things which blemish perfect purity, without being in themselves downright acts of impurity. Anything which tends to lessen its intense sensitiveness, or to cast the slightest shadow over it, is of this nature; and all evil thoughts or foolish acts of levity or heedlessness are as steps towards the most direct breaches of the law of chastity.
Avoid Bad Company
Avoid the society of persons who are wanting in purity, especially if they are bold, as indeed impure people always are. If a foul animal licks the sweet almond tree its fruit become bitter; and so a corrupt pestilential man can scarcely hold communication with others, whether men or women, without damaging their perfect purity -their very glance is venomous. On the other hand, seek out good and pure men, read and ponder holy things; for the word of God is pure, and it will make those pure who study it: wherefore David likens it to gold and precious stones.
Always abide close to Jesus Christ crucified, both spiritually in meditation and actually in holy communion; for as all those who sleep upon the plant called Agnus castus become pure and chaste, so, if you rest your heart upon our dear Lord, the very Lamb, Pure and Immaculate, you will find that soon both heart and soul will be purified of all spot or stain.
~St. Josemaria Escriva recommends acts of mortification. He asks : “To defend his purity, St. Francis of Assisi rolled in the snow, St. Benedict threw himself into a thorn bush, St. Bernard plunged into an icy pond. And you? What have you done?”