Welcome to JUB!
What happens quite often is this. You're used to jerking off to porn, or even camming. Now think about doing one of these things, and you hear someone else coming home. What do you do? Probably zip up, turn off the computer, and pretend nothing's happening, right?

This sort of puts your brain into a certain mode - "sex is a solitary activity." So when you go to actually have sex...well, fuck, how can you when there's this other GUY in the room, you know?
So what can you do? A few things.
First off, just be aware of it. Be aware that it might happen (again). Secondly - and this is key - don't treat it like it's any big deal. Because it isn't. Almost all guys have had issues with their dicks not responding the way they want - either not rising to the occasion, not wanting to finish, or finishing too soon. Just own up to it. "Looks like I'm having a bit of performance anxiety. No worries - I'm still having a great time."
Thirdly, focus on HIM for awhile. Don't worry about what your dick is or isn't doing. Work on making HIM feel good, with your hands, mouth or any other body part. And fourthly, if he's done, and you're still not getting there, ask if he'll try something. Have him sit on the bed, and you sit just in front of him. Have him hug you from behind, caress your nipples, kiss your neck, lick your ear. And you? Just jerk off. Close your eyes if you want to. This may be closer to what you've done before, and might help you get to orgasm.
But - this is most important - just enjoy it. Orgasm or no. Don't try to force yourself into orgasm, because that rarely works. Just enjoy the feeling of him behind you, doing what he's doing, while you jerk off. If you feel yourself plateauing, don't push it. Stop, turn around, smile and say "That was great." If he points out that you didn't cum, just shrug it off. "Not this time. Maybe next time. But it doesn't matter - I still had an amazing time."
Lex