Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) said: "When one of you is in doubt in his prayer, let him estimate in his mind what is correct, then complete the prayer on that basis, then perform the two prostrations of forgetfulness (sajdah al-sahw) after the salam while sitting."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 9150