A boy died and had not done Hajj; can Hajj be done on his behalf?
If this child had reached puberty, and in his case the conditions of Hajj being obligatory were fulfilled, but he did not do Hajj (even though he had sufficient money to travel and do Hajj), and he left behind sufficient wealth to do Hajj, then it is obligatory for his heirs to allocate funds from his estate, before dividing it, for Hajj to be done on his behalf.
That is because Hajj is a debt owed to Allah, and the debt owed to Allah is more deserving of being paid off.
It makes no difference whether Hajj on his behalf is done by a relative or someone else.
Please see the answer to question no. 9124
It says in ash-Sharh al-Mumti‘ by Shaykh Ibn ‘Uthaymeen (7/42-43): Whoever meets the conditions (of Hajj and ‘umrah being obligatory), then he dies, the costs of Hajj and ‘umrah must be set aside from his estate, before shares of inheritance and bequests are allocated, because that is a debt, as the Prophet (blessings and peace of Allah be upon him) said: “The debt of Allah is more deserving of being paid off.” Narrated by al-Bukhaari (1852). So funds should be taken from his estate sufficient for Hajj and ‘umrah, then whatever is left is for payment of bequests and the shares allocated to heirs. That should be taken from his estate, whether he left instructions to that effect or not, just as if he owed a debt, we would take it from his estate, whether he left instructions to that effect or not.… From the words of the author it is known that if a person died and did not leave any estate, then no one is obliged to do Hajj on his behalf. End quote.
But if this boy died before reaching the age of puberty, or if Hajj was not obligatory for him, because he did not own sufficient wealth for Hajj, then it is not obligatory to do Hajj on his behalf, because Hajj was never obligatory upon him, so it is not obligatory upon anyone else on his behalf.
For more information on the signs of reaching puberty, please see the answer to question no. 70425.
For more information on the conditions of Hajj being obligatory, please see the answer to question no. 41957.
For more information, please see the answer to question no. 117168.
And Allah knows best.