In the beginning of Siman 318, Maran writes that if one did a prohibited Melacha on Shabbat, it is forbidden to derive benefit from that action. Sometimes it's forbidden until Mosa'eh Shabbat, and sometimes it is forbidden forever. It depends on whether the violation was B'Shogeg (unintentionally) or B'Mezid (intentionally) and who wants to benefit-the violator or someone else.
The classic example is a case in which one cooked food intentionally on Shabbat; that food is forbidden to him forever. However, Hacham Ovadia writes that in other Melachot, besides cooking, where the benefit from the Melacha can be neutralized, the problem can be avoided.
For example, Borer is prohibited on Shabbat. That is, one may not select the "bad" from the "good" in a mixture. However, if he did so, the mixture does not become forbidden, because he can return everything to the mixture, neutralizing the benefit of his action and start over in the proper way. Of course, he still has to make Teshuba to repent for his transgression.
Another case would be where one laundered a garment intentionally on Shabbat, violating the Torah prohibition. According to Maran, that garment should seemingly be forbidden to him forever. However, Hacham Ovadia writes that he can soil the garment again and revert it back to its original state. That way, he has no benefit from his transgression and may then launder the garment again after Shabbat and benefit from it.
Of course, this principle only applies to Melachot such as Borer and Laundering, which can be reversed. Cooking cannot be reversed, and the food will remain forbidden forever.