حَدَّثَنَا أَبُو سَلَمَةَ بْنُ السَّبَّاكِ ، حَدَّثَنَا مَخْلَدٌ ، عَنِ ابْنِ جُرَيْجٍ ، عَنْ عَبْدِ اللهِ بْنِ مُسَافِعٍ ، عَنْ عُقْبَةَ بْنِ مُحَمَّدِ بْنِ الْحَارِثِ ، عَنْ عَبْدِ اللهِ بْنِ جَعْفَرٍ ، أَنَّ رَسُولَ اللهِ - صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ - قَالَ : مَنْ شَكَّ فِي صَلَاتِهِ فَلْيَسْجُدْ سَجْدَتَيْنِ بَعْدَمَا يُسَلِّمُ .
It is narrated from Sayyiduna Abdullah bin Ja'far (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever has a doubt in his prayer (concerning the number of rak'ahs or the like), let him perform two prostrations (the prostration of forgetfulness) after giving the salam."
Related hadith on this topic