From Fatawah Islamiyyah Vol. 1 and 2
The Remedy for Whispering (of Shaytan) in the Prayer
When I begin to pray, I am afflicted by a kind of whispering and thoughts, and sometimes I do not know what I have recited, not how many Raka’ahs I have prayed. Please advice me.
It is prescribed for the worshiper, man or woman, to approach the prayer with humility towards Allah and to call to mind that he stands before his Lord, so that Shaytan will stay away from him and the whispering will be reduced, in implementation of Allah’s Words: “Successful indeed are the believers. Those who offers their prayers with all solemnity and full submission.” [Soorah Muminoon (23): 1-2]
If the whispering become frequent, it is prescribed to seek refuge with Allah, from Shaytan, as the Prophet (sallallahu alaihi wa-sallam) ordered Uthman Ibn Abi al-As when he informed him (sallallahu alaihi wa-sallam) that Shaytan had confused his prayers. And when the worshiper becomes confused as to the number of Raka’ahs he has prayed, he should assume the minimum, base his estimation upon what he is sure of, and then complete his prayer. Afterwards, he performs two prostration of forgetfulness before making the Tasleem, based upon the narration of Abu Said (radhi allahu anhu) from the Prophet (sallallahu alaihi wa-sallam) in which he said: “If any of you is in doubt regarding his prayer, and he does not know how much he has prayed, three or four (Raka’ahs) then let him cast aside doubt and base his estimation upon what he is sure of. Then prostrate twice before making the Tasleem; if he has prayed five, his prayer will be an intercessor for him, and if he has completed the prayer correctly, it will be a humiliation for Shaytan.” [Saheeh Muslim (571)], And Allah is the Grantor of success.
Shaikh Ibn Baz (rahimahullah)