In previous generations people in Morocco would bring their food to be cooked in a communal oven. An issue that arose in those days was that people would send their Dafina pots to the communal oven before Shabbat and a non-Jew would be in charge of placing them in the oven to be cooked. (Regarding the issue of Bishul Akum, cooking by a non-Jew, it is assumed that the food was already partially cooked to circumvent the problem). Due to the sheer volume of pots that were sent to the communal oven and the limited time before Shabbat, it sometimes happened that people’s food was placed by the non-Jew in the oven on Shabbat itself. This led to a Halachic quandary of whether or not the non-Jew was allowed to perform a forbidden act on Shabbat on behalf of a Jew.
Rabbi Yitzhak Benoualid (Vayomer Yitzhak, Orah Haim, § 25), responding to this situation, writes that if there is not enough time before Shabbat for the food to be cooked, it is as though one is assenting to the food being cooked by the non-Jew on Shabbat itself, and is therefore forbidden. If, however, the Jew sent the pot of food at a reasonable time before Shabbat but the non-Jew decided on his own to delay placing it into the oven until after Shabbat began, then it would be permitted.
Nevertheless, Rabbi Eliezer di Avila (Ma’ayan Ganim), Rabbi Shalom Messas (grandfather of the better known Rabbi Shalom Messas; Divre Shalom, Orah Haim, § 1) and Rabbi Shalom Messas (Tevuot Shamesh, Orah Haim, § 48) rule stringently by saying that even if the pot is sent in a timely fashion, if it is known that the non-Jew may possibly place it in the oven Shabbat, it is akin to expressly asking him to do so.
To clarify, telling a non-Jew to perform a forbidden act is only a rabbinic prohibition. There are several levels of this act. Firstly, all opinions agree that one may not tell a non-Jew to perform a biblically-forbidden act on Shabbat on behalf of the Jew. Next, there is a difference of opinion among the Poskim when the Jew does not tell the non-Jew to perform a forbidden act on Shabbat itself but the non-Jew does it on his own, like the example discussed. A third scenario is when the act being performed by the non-Jew is forbidden Rabbinically. Since telling a non-Jew to do something on Shabbat is only problematic on a Rabbinic level, and since the act itself is only forbidden Rabbinically, there is more leniency with this scenario. This doubling of Rabbinic injunctions is known in the Talmud as a Shvut d’Shvut. The Shulhan Aruch (O.H. 307:5) rules that one could be lenient with such a Shuvt d’Shvut when a minor illness, financial loss or a Mitzvah are involved. For example, one may tell a non-Jew explicitly to move Muktzeh away from the Teva so that the Torah may be placed and read on top of it.
Summary: A Jew may ask a non-Jew to perform a Rabbinically forbidden act on Shabbat if it for a Mitzvah, to prevent financial loss or if one has a non-life threatening illness.