Fasting is not going to cure your problem. You must learn how to meditate and transmute your sexual energy. This is not something done in a few days. It is a process.
Your mind, just as anyone's, is the result of many lifetimes of mistaken actions. It will not be resolved with just a week or year of effort. Fasting is similar to tranquilizing a beast. The beast will become pacified, it may even appear to be dead. However, one day you must eat again. The beast will rise and you will return to your full self. Fasting only weakens the physical body, and may even kill it. But it does nothing to the ego, nothing at all. Even if you fast until your body dies, your ego will remain exactly the same. It will be a wasteful effort.
There are many audio lectures about this. Such as "How to Know the I", "Gnostic Psychoanalysis", "The Three Factors", Self-knowledge.
You can find links to download them here: http://gnosticteachings.org/download/beginning-here-and-now-introductory-lectures.html