The episode you're referring to is "The Last Temptation of Homer" (from Season 5), and said woman is Mindy Simmons. It wasn't Homer imagining it; what happened was Homer and Mindy come to an agreement to not take the sexual attraction that they had for each other further than that. Homer was convinced he had to have sex with Mindy because she seemed perfect for him, but when Mindy told him he didn't have to do what he didn't want to and should follow his heart, he decided to stay with Marge, so Mindy left and Marge roomed with Homer in the hotel room. It happened off screen so it doesn't specifically say it, but the implication is clearly there. Definitely wasn't Homer's imagination; would be especially odd, considering Mindy was working at the power plant.