Q) If a person offers a sacrifice on behalf of his deceased father or gives charity on his behalf or prays for him, and visits his grave, will he be aware that it is from his son so-and-so?
A) Praise be to Allaah.
What is indicated by the Islamic texts is that the deceased benefits from charity given by the living on his behalf, and his prayers for him. Offering a sacrifice on his behalf is a kind of charity, so if the giver is sincere in giving charity on behalf of the deceased and in praying for him, then the deceased will benefit from that, and the one who prays for him or gives charity on his behalf will be rewarded, by the grace and mercy of Allaah. It is sufficient for him that Allaah knows of his sincerity and good deed, and He will reward both parties. But as for the deceased being aware of the identity of the one who is doing him this favour, there is no shar’i evidence concerning that as far as we know. It is a matter of the unseen, and cannot be known except through revelation from Allaah to His Messenger (blessings and peace of Allaah be upon him).
And Allaah is the source of strength. May Allaah sent blessings upon our Prophet Muhammad and his family and Companions. End quote
Standing Committee For Academic Research and Issuing Fatwas
Fataawa al-Lajnah al-Daa’imah, 9/ 32