The Shulhan Aruch rules that it is entirely permissible to warm a cloth on Shabbat and place it on one’s stomach, either to alleviate stomach pain or for warmth. As long as the towel is dry, warming it violates no Shabbat prohibition, and there is certainly no prohibition against placing a dry cloth or towel on one’s skin on Shabbat. The Shulhan Aruch adds that this does not violate the prohibition against Refu’a (performing medical procedures) on Shabbat, because even healthy people put warm cloths on their bodies for warmth. As such, it is permissible even for medicinal purposes.
However, the Shulhan Aruch does forbid placing a bottle with hot water on one’s body on Shabbat. Unlike in the case of a dry cloth, when handling a water bottle there is the concern that some water might spill from the bottle onto one’s skin. This presents a twofold problem – first, it would violate the prohibition against bathing on Shabbat, and second, even during the week, this could be very dangerous, given the risk of burning. Therefore, the Shulhan Aruch writes that one should not place a hot water bottle on his skin.
However, since the concern is purely that some hot water might spill on the person’s skin, later Halachic authorities – including Hacham Bension Abba Shaul (Israel, 1924-1998) – note that this ruling does not apply to sealed water bottles, which do not drop or spill. Therefore, it is permissible on Shabbat to fill a water bottle with hot water from an urn (assuming, of course, that the water was heated before Shabbat), close the bottle tightly, and then place it on one’s skin. Hacham Bension adds that filling a bottle with hot water does not violate the prohibition of Hatmana – insulating on Shabbat – because Hatmana applies only to the utensil in which the food or liquid was cooked, whereas here, the water is transferred into a second utensil. This also does not transgress the violation of Refu’a, because, as mentioned, this is something which even healthy people do. Hacham Ovadia Yosef added another reason why this does not violate the prohibition of Refu’a, namely, because the Refu’a prohibition was enacted out of the concern that patients might grind herbs in order to produce medication on Shabbat, as was common in ancient times. As this is the basis for the Refu’a prohibition, Hacham Ovadia writes, this prohibition is limited to medicines that could potentially entail grinding herbs. This is clearly not the case regarding warming one’s skin with a water bottle, and so this does not fall under the Refu’a prohibition at all. (Indeed, the Shulhan Aruch addresses this topic in Siman 326, which deals with the prohibition against bathing on Shabbat, and not in the context of the laws of medicine on Shabbat, clearly indicating that he does not consider this an issue of Refu’a at all.)
For this reason, both Hacham Bension Abba Shul and Hacham Ovadia ruled that it is entirely permissible on Shabbat to fill a bottle with hot water that had been heated before Shabbat and place it on one’s skin. Although the Mishna Berura (Rav Yisrael Meir Kagan of Radin, 1839-1933) ruled stringently in this regard, and permitted placing a hot water bottle on one’s body on Shabbat only in situations of great need, the aforementioned authorities disagreed, and permitted doing so under any circumstances.
Summary: It is permissible on Shabbat to fill a bottle with water that was heated before Shabbat, close the bottle tightly to ensure water will not drip, and then place the bottle on one’s skin, either to alleviate pain or for warmth.