If a man resolves to do Hajj then dies, he must have died either before entering ihraam or after.
If he died before entering ihraam, then Allaah will reward him according to his intention, but the obligatory Hajj of Islam should be performed on his behalf.
If he died after entering ihraam, he will have the reward of Hajj, and he will be raised on the Day of Resurrection reciting the Talbiyah. Therefore Hajj should not be performed on his behalf.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked about a person who saved money to go for Hajj, but died before he was able to do so. He replied:
With regard to this man who resolved to do Hajj and sold all he had in order to go for Hajj, but died before he could perform Hajj, we hope that Allaah will record the reward of the pilgrims for him, because he intended to do a good deed, and he did what he could to prepare for it. Whoever intends to do a good deed and does what he can to prepare for it, it will be recorded for him (as if he did it). Allaah says (interpretation of the meaning):
“He who emigrates (from his home) in the Cause of Allaah, will find on earth many dwelling places and plenty to live by. And whosoever leaves his home as an emigrant unto Allaah and His Messenger, and death overtakes him, his reward is then surely, incumbent upon Allaah”
If this man had sold all his wealth in order to do Hajj because Hajj is an Islamic duty, then Hajj should be performed on his behalf after his death, using this money that he had prepared, by one of his heirs or by someone else. According to the hadeeth of Ibn ‘Abbaas (may Allaah be pleased with him), a woman came to the Prophet (peace and blessings of Allaah be upon him) and said: “O Messenger of Allaah, my mother vowed to do Hajj but she did not do Hajj before she died. Can I perform Hajj on her behalf?” He said: “Yes.” That was during the Farewell Pilgrimage. End quote.
Fataawa Ibn ‘Uthaymeen, 21/232
He was also asked: A man came from his homeland to perform Hajj, but the plane crashed before reaching (Saudi Arabia). Is he regarded as a hajji?
If a person who is travelling to Hajj dies before setting out, he is not a hajji, but Allaah will reward him for his deeds. If he had entered ihraam and then died, then he is a hajji, because the Prophet (peace and blessings of Allaah be upon him) said concerning a man whose she-camel broke his neck whilst he was standing in ‘Arafah: “Wash him with water and lotus leaves, and shroud him in his two garments, but do not apply perfumes to him or cover his head, for he will be raised on the Day of Resurrection reciting the Talbiyah.” He did not tell them to make up his Hajj, which indicates that he was a hajji. End quote.
Fataawa Ibn ‘Uthaymeen, 21/252.