The Shulhan Aruch (Orah Haim 330:6) writes that within thirty days after childbirth, if the woman feels cold on Shabbat, it is permissible to light a fire so she can be warmed. During the first thirty days after childbirth, the chills can be dangerous to the woman’s health, and thus the prohibition against lighting a fire on Shabbat is overridden by the concern for her wellbeing, and a fire may be kindled for her on Shabbat.
There were some earlier authorities, however, who ruled that this provision applies only for the first seven days after childbirth, and not for thirty days. Therefore, Hacham Ovadia Yosef writes that if a non-Jew is available and can be asked to turn on the heat for the woman in such a case – within seven and thirty days after childbirth – this would be preferable. But if no such possibility exists, it is permissible to turn on the heat, in accordance with the ruling of the Shulhan Aruch.
Incidentally, it should be noted that whenever people are cold on Shabbat, it is permissible to ask a non-Jew to turn on the heat. People experiencing discomfort because of cold temperatures are considered “sick” with respect to Halacha. Therefore, just as it is permissible on Shabbat to ask a non-Jew to perform Melacha that is needed for an ill patient, it is likewise permissible to ask a non-Jew to turn on the heat if people are uncomfortably cold on Shabbat.
When a baby is born on Shabbat, everything necessary to care for the child, such as the delivery, cutting the umbilical cord, tying the knot, bathing the baby in warm water, and anything else, is allowed to be done, even by a Jewish doctor. It should be noted that in Talmudic times, infants born during the eighth month of pregnancy were considered incapable of surviving, and thus Shabbat would not be violated for the sake of caring for these newborn babies. Nowadays, of course, when incubators are available to help prematurely-born babies grow after birth, the Shabbat prohibitions are set aside for the care of any newborn infant.
If there is concern of fetal distress during pregnancy, even in the fourth of fifth month of pregnancy, the mother may violate Shabbat to go to the hospital in order to take the fetus out of distress. In such a case, we apply the Gemara’s principle, “Halel Alav Shabbat Ahat Kedeh She’yishmor Shabbatot Harbeh” – “Desecrate one Shabbat for him, so he will be able to observe many Shabbatot.” It is preferable to desecrate Shabbat once to ensure the viability of a fetus, which will enable the child to be born and to then, please G-d, observe many Shabbatot throughout his or her life.
Summary: If a woman within thirty days of childbirth feels cold on Shabbat, one may turn on the heat to make her feel comfortable. However, in between the seventh day and the thirtieth day, it is preferable to ask a non-Jew to turn on the heat, if this option exists. Everything necessary to care for a newborn infant on Shabbat – such as for the delivery, cutting the umbilical cord, and all postnatal care – is permissible. This includes the special care need for an infant born prematurely. Shabbat may be violated even during earlier stages of pregnancies to take the fetus out of distress.