Praise be to Allah.
Saying “Yarhamuk Allah (may Allah have mercy on you)” to one who sneezes, if he praises Allah (by saying “al-hamdu Lillah” after sneezing) is part of the etiquette that is prescribed in Islam, and it is one of the rights that one Muslim has over another.
But if he does not say “al-hamdu Lillah”, then he is not entitled to have another person say “Yarhamuk Allah” to him.
Al-Bukhaari (6221) and Muslim (2991) narrated that Anas (may Allah be pleased with him) said: Two men sneezed in the presence of the Prophet (blessings and peace of Allah be upon him), and he said Yarhamuk Allah (may Allah have mercy on you) to one of them and not to the other. Something was said to him about that, and he said: “This one praised Allah (said Al-hamdu Lillaah) but that one did not praise Allah.”
It was narrated that Abu Burdah said: I entered upon Abu Moosa when he was in the house of the daughter of al-Fadl ibn ‘Abbaas, and I sneezed but he did not say Yarhamuk Allah to me, but she sneezed and he said it to her. I went back to my mother and told her. When he came to her she said: My son sneezed in your presence and you did not say Yarhamuk Allah, but she sneezed and you said it to her. He said: Your son sneezed but he did not praise Allah, so I did not say Yarhamuk Allah to him. She sneezed and she did praise Allah, so I said Yarhamuk Allah to her. I heard the Messenger of Allah (blessings and peace of Allah be upon him) say: “When one of you sneezes and praises Allah, then say Yarhamuk Allah to him, but if he does not praise Allah, then do not say it to him.”
Narrated by Muslim (2992)
An-Nawawi (may Allah have mercy on him) said:
This clearly indicates that it is enjoined to say Yarhamuk Allah if the one who sneezed praises Allah, and it is not allowed to say Yarhamuk Allah to him if he does not praise Allah; hence it is makrooh to say it to him if he did not praise Allah. But if he praises Allah, but the other person did not hear him, then he does not have to say Yarhamuk Allah to him. Maalik said: He should not say Yarhamuk Allah to him unless he hears him praise Allah. But if you see that someone next to him says Yarhamuk Allah to him, then you should also say it.
End quote from Sharh an-Nawawi ‘ala Muslim (18/121)
If the child has reached the age of discernment and is able to understand if you teach him manners, then it is prescribed to teach him to praise Allah if he sneezes, as it is proven that the Prophet (blessings and peace of Allah be upon him) taught the young boy the etiquette of eating, and he instructed Muslims to teach their children how to pray, and so on
Children and those who are new in Islam should be taught to say “al-hamdu Lillah.” By the same token, one who grew up in the remote desert should also be taught, because it is expected that one who grew up in such circumstances would be unaware of that.
If a child sneezes and praises Allah, one may say to him “May you be blessed” or “May Allah help you” or Yarhamuk Allah.” This was stated by Shaykh ‘Abd al-Qaadir.
End quote from Mataalib Ooli an-Nuha (1/945). See also Kashshaaf al-Qinaa‘ (2/158)
What appears to be the case is that the right of one who praises Allah (after sneezing) is applicable to both young and old, with no differentiation, and one should say in either case the same phrase: “Yarhamuk Allah”.
It says in Fath al-Mu‘een (4/219)
In al-Adhkaar, an-Nawawi did not differentiate between young and old with regard to saying Yarhamuk Allah (to one who praises Allah after sneezing).
End quote from Fath al-Mu‘een Sharh Alfaaz al-Mu‘een (4/219)
If the child is small and has not yet reached an age where he can learn, and he cannot yet pronounce the words “al-hamdu Lillah” properly, then some of the scholars are of the view that his guardian should praise Allah on his behalf, but what is more likely is that this is only required of the one who sneezes, and should not be done by someone else on his behalf. But if a person offers supplication (du‘aa’) for the child, saying whatever is appropriate, such as asking for mercy for him or that he become righteous, and so on, then we hope that there is nothing wrong with that, because the child is not being careless by omitting to praise Allah, and du‘aa’ for such a one is prescribed in general. But it should not be taken as a regular practice.
Ibn Muflih (may Allah have mercy on him) said in al-Adaab ash-Shar‘iyyah (2/343):
‘Abdullah ibn Ahmad narrated from al-Hasan that he was asked about a small child who sneezes. He said: It should be said to him: May you be blessed.
The author of an-Nazm said: If a child sneezes he may be prompted to say al-hamdu Lillah. Then it should be said: Yarhamuk Allah or May you be blessed and so on, and he should be taught how to respond.
If he is small, his guardian or someone else who is present may praise Allah, and similar phrases to those mentioned above may be said to the child. Ibn Muflih said: With regard to teaching the child the response, this is similar to the issue of returning the greeting (i.e., the two matters – the greeting and the response – should not be combined). But what appears to be the case, based on the view of other scholars, is that du‘aa’ may be offered for the child even if he does not say Al-hamdu Lillah. But it may be said that du‘aa’ is akin to saying Yarhamuk Allah, so it should be connected to him saying Al-hamdu Lillah, as in the case of an adult.. But the first view is more likely to be correct. And Allah knows best.
End quote from al-Adaab ash-Shar‘iyyah (2/327)
If a person sneezes whilst praying, it is prescribed for him to praise Allah, but he should not disturb others by doing so or distract them from their prayer.
If he sneezes and does not praise Allah, then it does not matter.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
If a person sneezes, whether whilst praying or otherwise, it is not obligatory for him to say Al-hamdu Lillah, but it is preferable and more appropriate. But if he does not praise Allah, he is not sinning.
Praising Allah after sneezing is prescribed for people when praying and when not praying, unless he is praying and is afraid of disturbing other worshippers, in which case he should praise Allah quietly and not say it out loud, because there is the worry that if it is said out loud, he will disturb other worshippers or cause somebody to say Yarhamuk Allah (reflexively). If someone says to the one who sneezes and then praises Allah, “Yarhamuk Allah”, and the one who says it is praying at the time, then his prayer is rendered invalid.
End quote from Fataawa Noor ‘ala ad-Darb (5/313)
See also the answer to question no. 106435
And Allah knows best.