The Rama (Rav Moshe Isserles of Cracow, 1530-1572) establishes (in Orah Haim 328:17) that a child has the status of a "Holeh She’en Bo Sakana" (an ill patient whose condition is not dangerous) with respect to the laws of Shabbat. This means that whereas adults may not take medication on Shabbat unless they are ill to the point where they need to lie down, children are considered "ill" and may be given any medication that they need, under any circumstances. This applies to all forms of medication – syrups, eyedrops, eardrops, tablets or capsules. Even if the child did not begin taking medication before Shabbat, he may be given any medication he needs on Shabbat, without any restrictions. Hacham Bension Abba Shaul (1924-1998) writes in his Or Le’sion that this refers to all children who have yet to reach the age of Bar-Misva.
Hacham Ovadia Yosef was asked whether this Halacha applies also to gels, such as gel applied to the gums of infants who are teething and experience considerable pain. Although children are not included in the prohibition of Refu’a (medication) on Shabbat, there is a separate prohibition of Memare’ah, which forbids smoothening out a substance on Shabbat. Is there room to allow applying gel in the case of a child suffering from teething pain?
Hacham Ovadia ruled leniently, based on a discussion of the Magen Abraham (Rav Abraham Gombiner, 1633-1683) concerning the parameters of Memare’ah. If somebody had expectorated on the ground, and he wishes to rub it into the earth with his feet, this is forbidden, because in the process he might end up filling holes in the ground with earth, which would violate the prohibition of plowing on Shabbat. If, however, this happened not on the ground, but on a solid surface, one may rub the spit into the ground, because there is obviously no concern of filling holes with earth. The Magen Abraham raises the question of why this is not forbidden by virtue of the fact that the substance is being smoothened, seemingly in violation of Memare’ah. To answer this question, the Magen Abraham establishes a very important principle, stating that Memare’ah does not apply when the substance which is being smoothened is absorbed into the surface. This prohibition forbids smoothening out a substance on a surface, but not smoothening it such that it is absorbed into a surface.
Hacham Ovadia ruled that we may rely on this leniency of the Magen Abraham in cases of a child, and we may therefore allow applying gel to a child’s gums to alleviate teething pain. By the same token, Hacham Ovadia allows applying cream to a rash on an infant’s skin. Although the Hazon Ish (Rav Avraham Yeshaya Karelitz, 1878-1953), in one place in his writings, rules that cream may be dabbed onto an infant’s skin, but not smeared, Hacham Ovadia noted a different source where the Hazon Ish ruled leniently in this regard, and allowed smearing cream. Hacham Ovadia likewise permitted those suffering from very painful backaches to apply creams to the skin to alleviate the pain, in accordance with the lenient position of the Magen Abraham.
Summary: Children below the age of Bar-Misva may be given any medication they require on Shabbat, under any circumstances, without any restrictions. This applies even to applying gel to aching gums and cream to rashes. Although in most cases smearing gels and creams on skin is forbidden on Shabbat, in the case of a child (or in the case of an adult experiencing significant pain) this is allowed.