Debunking common misconceptions...
The first thing that we need to clarify is that there are two separate prohibitions involved in having a non-Jew perform a forbidden act for us on Shabbos and Yom Tov.
1. The first prohibition is asking them to perform the act, even if asked before Shabbos (as explained below).
2. The second prohibition is that we may not benefit from a forbidden action (Melacha) performed on our behalf on Shabbos or Yom Tov. So much so that if a non-Jew sees us sitting in a dark room and walks past and turns on the light for us, even if we didn't ask or hint to them to do so, we must leave the room as we may not derive benefit from it (Shulchan Aruch O.C. 307:20). This example helps demonstrate the general severity of this law.
There are however some exceptions, namely:
When the non-Jew benefits
Rabbinical prohibitions for some Mitzvahs
Rabbinical prohibitions for extreme need - צורך גדול
Bein Hashmashos, i.e. during twilight
P’sik Reisha, i.e. when the Melacha is not desired
We will begin detailing when and how these can be used.
WHEN THE NON-JEW ALSO BENEFITS
If the non-Jew also benefits from the action, e.g. if they turn on the light in a dark room and then enter the room, one may stay in the room as the Melacha was done for themselves (Shulchan Aruch O.C. 325:10). Keep in mind that one may still not ask or even hint to the non-Jew to do the Melacha (unless another relevant exception is applicable). This includes even if one instructed the non-Jew before Shabbos (Shulchan Aruch O.C. 307:2, see also Avnei Nezer O.C. 43:6).
This can be used creatively, for example, one could create a situation whereby turning on the light is beneficial for the non-Jew. So one could place a bottle of whiskey or a gift of chocolate in a dark room, then invite the non-Jew in, and if he turns on the light, we are permitted to benefit from it. This is because 1) the non-Jew turned on the light for his own use, and 2) the Jew did not ask him to turn on the light.
However, one must be cautious and ensure that the non-Jew is indeed doing the Melacha for his own purposes, such as mentioned above. However, one may not ask a non-Jew to accompany them on a tour of a dark room after which he turns on the light to see his way. This is prohibited because the non-Jew is interested in the light only in order to accompany you on the walk, not because he inherently gains anything (see Shulchan Aruch O.C. 276:3).
We will BeH continue this topic next week.