Under normal circumstances, one may not ask a non-Jew to perform melakha on Shabbat. However, for the sake of a sick person, one may ask a non-Jew to perform melakhot, even those that are prohibited by Torah law. These leniencies apply even to one who is not dangerously ill. If one is dangerously ill, then even a Jew must desecrate Shabbat in order to help him, as saving a life overrides Shabbat (SA 328:17). The laws pertaining to sick people will be explained below in chapters 27 and 28.
A child who needs something very badly has the same status as a sick person, and one may ask a non-Jew to do even melakhot that are prohibited by Torah law on his behalf. Therefore, one may ask a non-Jew to cook for a child who has nothing to eat or to turn on a light in the home of children who are very scared of the dark (Rema 276:1; MB ad loc. 6; Rema 328:17; 24:6 above).
In the cold areas of northern Europe, keeping homes warm on Shabbat was an ongoing struggle. Since homes were generally heated by coal- or wood-burning stoves, by Shabbat morning the fuel supply would be depleted and the fire in the stove would go out. Since all people are considered ill when it comes to extreme cold, the rabbis permitted asking a non-Jew to come and light the stove on Shabbat morning (SA 276:5). The non-Jew who did this was known as the “Shabbos goy.” Nowadays, however, when heaters are powered by electricity or gas and do not run out during Shabbat, there is no justification for using a “Shabbos goy” on a regular basis. Only if, by chance, the heater went off and it is extremely cold, may one ask a non-Jew to turn on the heat. One may do this even if there are no small children. In a home with children who truly need the heat, one may ask a non-Jew to turn on a heater even if it is not extremely cold (SSK 23:28; see n. 87 ad loc.).
Permission to ask a non-Jew to do melakhot that are prohibited by Torah law is limited to the needs of the ill. For one who is suffering but not ill, one may ask a non-Jew to perform a rabbinically prohibited melakha but not one that is prohibited by Torah law. Based on this, some maintain that on a hot day one may ask a non-Jew to turn on an air conditioner, claiming that turning on an air conditioner is only rabbinically prohibited. Accordingly, for the sake of the mitzva of oneg Shabbat, and in order to alleviate great suffering, one may ask a non-Jew to turn on an air conditioner. However, since others maintain that turning on an air conditioner is prohibited by Torah law (17:2 above), it is proper to ask the non-Jew to turn it on using a shinui (for example, using a teaspoon to depress the air conditioner’s on button), which renders the action a shvut di-shvut.
If the air conditioner is running and has gotten too cold, one may ask a non-Jew to turn it off. Preferably, one should simply tell him that it is too cold, and allow him to figure out on his own that he should turn off the air conditioner. If he does not take the hint, one may tell him directly.