In the name of Allah, the Compassionate, the Merciful. May his abundant blessings be showered on his beloved prophet, the best of creation.
The Hajj offered on behalf of another may be Nafl or it may be Fard. The rulings regarding both are mentioned below:
In the case of a Nafl Hajj offered on behalf of others who are alive or deceased, it is valid and the reward will reach them even in the case of their being unaware of the hajj being offered on their behalf, such as in the case of deceased loved ones.
As for the Fard Hajj which becomes obligatory on an individual, then due to illness or any other reason that individual is unable to fulfill it, an essential condition for the discharge of this obligation on behalf of that person is he/she must expressly command another to carry out the Hajj on their behalf, or at least the hajj should be performed with their permission.
Given this, if a person upon whom Hajj was an obligation and he did not fulfill it, nor did he expressly request a relative etc. to perform it from his estate after his death, upon this person’s death if a relative chooses to offer the Hajj on behalf of him from his personal wealth (not the estate of the deceased), the obligation should not be discharged, due to absence of express request.
However it is reported from Imam Abu Hanifah that he held the Hajj discharged based an a certain Hadith he interpreted to mean as such, emphasizing that this is more close to Allah’s mercy and compassion with his slaves. [Mufti Mohammed Shafi': Jawaahirul Fiqh vol. 1 page 501]
And Allah knows best.