Despite the continuous attempts made by Potiphar's wife to try to seduce Yosef, he maintained his righteousness and did not sin with her: "And she spoke to Yosef day after day, and he did not listen to her to lie next to her, to be with her" (Bereishis 39, 10). Rashi explains the seemingly redundant language of the pasuk, "to lie next to her, to be with her. "To lie next to her" was said in reference to this world, while "to be with her" refers to the World to Come. Had Yosef sinned with Potiphar's wife, he would have ultimately ended up together with her in the next world. What is the meaning of this ambiguous statement?
Rav Wolbe (Shiurei Chumash) explains that every action performed in this world does not end with the completion of the action. Rather, it creates a spiritual reality that continues into the World to Come. This spiritual reality is the reward or punishment one receives in olam haba. In other words, each mitzvah performed in this world is made up of two parts: the physical action and the spirituality that the mitzvah produces. Likewise, each aveirah contains both of these aspects. When one reaches the next world and has the ability to perceive the spiritual side of his actions, he becomes cognizant of the magnitude of those actions. Recognizing the enormity of the positive spirituality produced by his mitzvah is in and of itself the reward for that mitzvah, while perceiving the magnitude of his aveirah is the very punishment itself. This is what Chazal meant when they said (Avos 4, 2) "The reward for a mitzvah is a mitzvah, the reward for an aveirah is an aveirah." Had Yosef sinned with Potiphar's wife, the aveirah would have accompanied him to the next world.
An aveirah isn't "over" at the end of the transgression. As Chazal tell us (Sotah 3b) an aveirah surrounds the transgressor and cleaves to him like a dog until the World to Come where it turns into the punishment for that very aveirah. If this is true with regard to aveiros, how much more so does it apply to mitzvos. It behooves us to bear in mind that the magnitude of our every action is astounding!