Bismillah ar-raman ar raheem…
The Messenger of Allah (sallAllahu alayhi wa sallam / may Allah bless him and grant him peace) said: “When a man dies, his deeds come to an end except for three things: Sadaqah Jariyah (continuous charity); knowledge which is beneficial; or a virtuous descendant who prays for him (the deceased).” [Sahih Muslim]
“His deeds come to an end” means that he/she is not able to perform any deeds any more and therefore does not receive reward for actions anymore. But there are three categories of actions for which he/she can receive reward even after death.
First, Sadaqah Jariyah: This is any good deed done from which people continue to benefit despite the demise of the person who originated it. For example, the establishment of a madrassa or masjid (mosque) from which people are rightly guided will be sadaqah jariya (continuous charity) for the person who established it. Having a well dug or a shade or fruit tree planted will also accrue good deeds for a person, as long as the well or tree benefits people.
Second, “knowledge which is beneficial” means knowledge imparted verbally or by any other means through which people become better Muslims. As long as people benefit from this knowledge, the teacher will receive reward for it.
A third source of reward is having virtuous descendants. Training of children on the right lines and then making dua for them to be among the righteous is essential, so that after a person’s death they continue to pray for him or her. The prayer of righteous children in favour of parents is very useful.
Needless to say, all such deeds have to be done with sincerity (ikhlas) in seeking the pleasure of Allah (subhana wa ta’aala). Only when they are done to earn His pleasure will they be rewarded by Him.