Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) says that the Messenger of Allah (peace and blessings be upon him) said: "When anyone has doubt about his prayer, let him discard the doubt and act on what is certain, and when the prayer is complete, let him perform two prostrations. If his prayer was already complete, this rak'ah and the two prostrations will be supererogatory (nafl); and if he had not completed the prayer, this rak'ah will complete his prayer, and these two prostrations will be a cause of humiliation and disgrace for Satan."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3883