The bad guy tells him that he will let him live only if he passes his personal “lie detector test” (which is a gun pointed in the face). One of the questions was did he sleep with his wife. Then there’s a flashback scene where we see that he didn’t sleep with the bad guy’s wife. But he decided to answer “yes”, as that would be more believable and successfully passes that question.
It is 90s or early 2000s movie or some TV series episode.