It is narrated from Sayyiduna Abu Hurairah (may Allah be pleased with him) that the Noble Prophet (peace and blessings be upon him) said: "When a person dies, his deeds come to an end except for three things: knowledge from which benefit is derived, or a charity that continues on his behalf, or a righteous child who prays for him."
Related hadith on this topic