The prohibition on deriving benefit on Shabbat from the unknowing performance of a melakha applies only to a case of a melakha that is prohibited by Torah law. In contrast, if a rabbinically prohibited action was done unknowingly, one may benefit from it on Shabbat. Nevertheless, if it was done knowingly, it has the same status as a Torah prohibition: one may benefit from it only after Shabbat (MB 318:3 and BHL ad loc.; Yalkut Yosef 318:3). For example, the Sages prohibited separating teruma, ma’aser, and ĥalla on Shabbat, because it resembles tikun (fixing or improving) of the produce. If one unknowingly performed the separation on Shabbat, the “improved” produce may be eaten on Shabbat, but if he did this knowingly, it may not be eaten until after Shabbat (MB 339:25; above 22:5).
If one unknowingly turned on an electrical appliance without a heating element (e.g., a fan, air conditioner, or refrigerator), since some maintain that this action is not prohibited by Torah law, one who wishes to be lenient and benefit from the appliance has an opinion on which to rely. However, if one turned on a heater with metal heating coils or a light bulb with an incandescent filament, he has definitely transgressed a Torah prohibition. Thus, even if it was done unknowingly, he may not benefit from the results of his action on Shabbat. In the case of the heater, he should open the window or leave the room to avoid benefiting from the melakha.
If one performed a melakha obliviously (mitasek), there is no prohibition on deriving benefit from it, since the melakha had no intent. This is true even if the melakha is prohibited by Torah law. For example, if one absentmindedly brushed his hand or leaned against a light switch and turned it on, one may derive benefit from it.
There is a difference between shogeg and mitasek. As noted, shogeg means that one was aware of his actions but forgot that it was Shabbat or was unaware that this act is a forbidden melakha on Shabbat. When the Temple stood, one who did a melakha be-shogeg was obligated to bring a sin offering. In contrast, mitasek means that one did a melakha obliviously, without being aware of his actions. Such an act did not obligate its perpetrator to bring an offering. Since mitasek is less severe than shogeg, there is no prohibition to benefit from what was done obliviously.
However, if one absentmindedly turned on a light out of habit, as he does all week long when entering a room, he is considered shogeg. Even though he was not thinking explicitly about what he was doing, nevertheless since the intent of his action was to turn on the light, he is considered shogeg and one may not derive benefit from his melakha.
. Among those who say mitasek does not constitute a transgression are Leĥem Mishneh (1:5) and Eretz Tzvi §76. Some are stringent and maintain that even mitasek constitutes a transgression, and therefore one may not derive benefit from a melakha done be-mitasek (Oneg Yom Tov; Minĥat Barukh). According to R. Akiva Eger, in some cases mitaskek has the same status as shogeg. Nevertheless, in practice, one may be lenient in all cases of mitasek. First, the prohibition on benefiting from melakha done on Shabbat is rabbinic, so in cases of uncertainty we are lenient. Second, the poskim who follow R. Meir are permissive even in the case of shogeg. This is also the opinion of Az Nidberu 6:17 and Yalkut Yosef 318:23. See Orĥot Shabbat 25:4.