The vast majority of sins in the Torah involve action only and therefore it is irrelevant if you think about sinning in your head. This is contrary to what the Charedim say. However, a few sins in the Torah involve the thoughts in your mind and you are responsible for thinking about sinning with regard to these sins. For example, if you doubt that G-d exists in your mind than this is a Biblical sin. But if you think about killing someone but don't do it this is not a sin (unless he's a Jew then you sin by not loving your neighbor as yourself, but don't sin with regard to being responsible for murder). If you covet a married woman and think about having sex with that woman than that is a sin but if you merely think about having sex with a single girl then that isn't a Biblical sin since the Biblical sin involves action only, not thought. The accepted opinion of the Rabbis prohibit lusting after single women as well, but this is not a Biblical prohibition.