Praise be to Allah
Our advice to you, first of all, is to consult a psychologist; and try to find a Muslim doctor so that he will understand your problem. Secondly, you have to always take the easier option, and do not think about the sin or punishment. If you do not follow this advice, your problem will continue. In a prayer when you are not sure whether you have prayed three or four rak’ahs, you have to assume that it is four, and the part of the body which you are unsure whether you have washed, you have to assume that you have washed it. This applies to every situation you face: take the easier option. If you do that you will have defeated the Shaytan who has subjected you to this involuntary/compulsive waswas.
May Allah heal you and grant you good health.