All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Moreover, if he is resolved on doing it and then he leaves it out of fear of Allaah, then he is forgiven for it and a good deed is written on his behalf. Evidence for this is the Hadeeh in which the Prophet said: “Allaah has forgiven my nation for the thoughts that they have except if they speak about them or act upon them.” [Al-Bukhari and Muslim].
Another Hadeeth reads: “If he thinks of doing a bad deed but he does not do it, Allaah will write it down as one complete good deed.” [Al-Bukhari and Muslim]
Therefore, we advise you not to think about this matter as these are whispers from the devil. He does so in order to grieve you. Therefore, you should avoid his plots and seek refuge in Allaah from such thoughts. Allaah says (what means): {And if there comes to you from Satan an evil suggestion, then seek refuge in Allaah. Indeed, He is the Hearing, the Knowing.} [Quran 41:36]
Beware of these thoughts becoming obsessive whispers and hindering you from what benefits you in your religion and your worldly affairs.
We should point out that it is not permissible to go to magicians even with the intention of undoing magic. Jaabir narrated that the Prophet was asked about undoing magic and he said: “It is from the work of the devil.” [Ahmad]
Ibn Al-Qayyim said: “Undoing magic is of two kinds:
1. Undoing magic with magic: this is the work of the devil. Al-Hasan Al-Basri said: “It’s only a magician who can undo magic; thus the person who is affected by magic as well as the magician do an act that is pleasing to the devil, and so the devil undoes the magic from the affected person.
2. Treating magic with Ruqyah, reciting Soorahs 112, 113 and 114 from the Quran, and permissible supplications, then this is permissible."
For more benefit, please refer to Fataawa 84806 and 88705.
Allaah Knows best.