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.
If a person is overcome by waswaas of kufr (obsessive whispers of disbelief) involuntarily, then he is not held accountable for them as long as he rejects them and is not content with them. The fact that these whispers increase when the person is indulging in sin does not necessitate being responsible for them.
In any case, one should stay away from sins and repent for the sins that he committed in the past. Sins are one of the causes of affliction, and repentance is one of the causes of the removal of affliction.
Allaah knows best.