Hi Missing Buddy,
It's a bit of a phenomenon but it does happen. There is a condition called Situational Erectile Dysfunction that
affects younger men. They can perform when they masterbate, but have
difficulty achieving an erection with their significant others and
wives. You can read more about Situational ED here.
Online sites are great for getting the information to ask all the right questions but it can not take the place of a doctor's solid advice. If you think there is something that might be physiological, it might be best to encourage your man to go to the doctor.
Good luck and let us know how you are doing!Vicki M