I doubt that it's you or a problem with you. I have actually(unfortunately) had that problem with one of my girlfriends before, and trust me, it was definitely not a case of not having enough attraction to her, or something she was doing wrong! The issue was resolved of course, because I certainly couldn't let that happen anymore!! It was, (or could be for any man that had this problem) one of the following reasons, in my opinion:
1. Depression/anxiety that certain day were ruining the situation.
2. Side effects of certain meds'!
3. Serious issues that were taking up too much of the mind, resulting in poor quality at the moment!
4. The one that you WOULDN't want to hear, for example, not enough attraction toward the female, which in that case, there should be a serious conversation about where the relationship is going between the couple.
I really wouldn't stress about it too much, because chances are, it's nothing too bad. Like stated before, your best bet is to talk to him about it, and let him know that you are understanding about it, which in turn will make him feel more open and comfortable with you to be able to tell you anything.
Some men that would go through that, might be embarrassed or something to talk about it too much, so you should do anything you can to make him know that you care and that he can share anything with you. Don't feel stupid asking him, just do it in a very mellow and easy atmosphere(just the two of you of course), and don't make a huge deal about it, and I'm sure everything will work out fine for you.
Good luck with everything and I wish the best for you. Let us know if things are working out, or if there is any improvement. I'm glad to try and help anyone when I actually have the time to be on here that is. Later