Is this "Life Is For The Taking," a segment of the Playboy anthology film, Inside Out (1991)...?
Playboy does to softcore sex films what HBO's Tales from the Crypt did for horror. Contains the stories: "Brush Strokes"; "Shrink Rap"; "Doubletalk"; "The Leda"; "My Secret Moments"; "Life Is For The Taking"; "The Diaries"; "Love The One You're With"; and "My Better Half".
A user review offers a very brief synopsis of the segment:
6: 'Life is for the Taking': Scifi- Charlie, a prison inmate tries asto-projection to see if his wife, Linda is being faithful.
The story opens with two men conversing in a prison cell. They've been cell mates for a year and the older man, Eddie, is congratulating the younger man, Charlie, who's due to go home the next day to his beautiful wife, Linda.
Eddie suggests Linda may've been cheating though, as he claims his own first wife did. Charlie, who has a habit of tugging his left earlobe, says Linda would never do that, but Eddie's persistent speculation is clearly getting to him.
Eddie argues that if Linda has been seeing another guy, she'll probably be seeing him for one last time tonight, but the only way for Charlie to find out for sure would be to use astral projection to leave the prison and go check on her.
Charlie is sceptical at first, but Eddie insists that he's done it plenty of times and that that's how lifers like him cope with a life behind bars. Charlie decides to give it a shot and Eddie agrees to show him how after lights out.
Charlie's astral form then goes home, where he finds his wife alone and getting undressed. At first, he worries that she may've been cheating after all, but soon realises that she's been faithful and is still very much in love with him.
He returns to his cell, but finds he's unable to reenter his body. Eddie's own body is lying motionless on his bed. Then Charlie's body sits up and starts talking like Eddie, and Charlie realises that Eddie's spirit is now in his body.
The next day, Charlie watches in anguish as Eddie is released from prison in his body, with Linda having come to pick him up. Powerless to do anything about it, he heads back to his cell, despondent, and kneels by Eddie's body.
In the closing scene, a new inmate arrives in Charlie's cell and Charlie -- now in Eddie's body and still tugging his left earlobe -- asks him if he's married and opines that it must be hard for a woman to wait, "if you know what I mean..."
You can watch this segment at the Internet Archive. It begins at around the 1:16:30 mark and lasts about 12 minutes. Note that there is some topless nudity and mild sexual content.