Did you ever play with a couple of magnets when you were a child? If you did, you'll remember that the closer they got to each other, the harder it was to pull them apart.
Temptation is something like that. The more you dwell on it and the closer you let it get to you, the stronger its attraction will be. In fact, if you don't look out, the time may come when it will be almost impossible to pull away from it. Don't let that happen!
Why do I mention this? Because the first step you need to take is to flee from whatever is tempting you. Don't play with it or toy with it in your mind–get as far from it as possible. I have known of people who had to change jobs to keep away from something (or someone) that was tempting them to do wrong–but it was the only way to win. Paul told his young friend Timothy to "flee the evil desires of youth, and pursue righteousness, faith, love and peace" (2 Timothy 2:22).
Most of all, you need God's help to fight this battle. If you have never done so, turn to Christ and ask Him to come into your life. Then ask Him to fill your heart with His love and power, and to crowd out whatever is wrong in your life. God has promised that "when you are tempted, he will also provide a way out" (1 Corinthians 10:13). Ask him to show you the "way out"–and then take it.