Scenario: While marveling at the woman in your bed, you whisper, "You're gorgeous, Amy." Her eyes become as wide as saucers. Is she that charmed by your compliment? No, asshole, her name's Nicole, and she's not happy.
Solution: It's safe to say the moment is officially ruined. Rather than trying to play it off like it didn't happen, own up to your mistake. Apologize, and reassure you have no idea why the name "Amy" popped in your head. Convince her it must have been because you were watching Parks & Recreation earlier. Exception: If your ex's name is Amy, you're fucked.
And, just a suggestion—maybe take a moment to reflect on why you've said this. Have you regularly been thinking about someone else? Do some soul searching now, and hump later.