Obsessive–compulsive disorder (OCD) is a mental disorder in which a person feels the need to perform certain routines repeatedly (called "compulsions"), or has certain thoughts repeatedly (called "obsessions"). The person is unable to control either the thoughts or activities for more than a short period of time. Common compulsions include hand washing, counting of things, and checking to see if a door is locked.
Your fast is valid. Bad thoughts which annoy you will not harm your faith nor your worshipping Allah.
Repeating Isteghfaar and repeating Salawaat and repeating La Hawla wala Qowwata ILLA Billah and reciting Sura Tawheed is very useful always especially in driving away satanic thoughts.
The issue of over-analysing a specific scenario, or becoming scrupulous in matters of religion is not something new, and does unfortunately affect some people.
If it is not tended to in its early stages, then it can only be cured by psychological help or medical treatment.
If it is issues related to taharah/najasah, then you need to re-program yourself and corretly learn the ahkam, emphasising on the pleasure and spiritual benefit of 'ibadah, and not that it should be straining or negative.
I would recommend watching this short presentation I gave a few years ago:
You can recite this dua:
أعوذ بالله القوي، من الشيطان الغوي، وأعوذ بمحمد الرضي من شر ما قدر وقضي، وأعوذ برب الناس من شر الجنة والناس أجمعين، وسلم، تكف مؤونة إبليس والشياطين معه ولو أنهم كلهم أبالسة مثله
Also, it is recommended to eat pomegranate, as hadiths say it removes waswasah, piece by piece, and in the morning before breakfast.
With prayers for your success.
Just because you might have some doubts, or even excessive doubts about certain things, it does not mean you have "OCD". We must remember that such problems must be diagnosed by a psychologist or a professional in that field.
Scrupulosity starts off very innocently, due to one's concern about getting their religious acts right and valid. However, it turns in a very bad state that make one very miserable in the areas they suffer in.
Instead of feeling a sense of spiritual uplifting or inner-peace, waswasah becomes a burden and leads to hating religious practices.
Please watch this presentation: