I am sorry your marriage is struggling with this. I recommend a therapist for you and for your marriage.
You said, ‘times of inadequacy’. What does that mean? It seems that feeling is what drives you. Are you looking for affirmation from women online in order to feel desirable? Are you flirting, sexting, meeting them and being physical? How far do you take it? Not that I am saying any of that would be acceptable to your wife, but perhaps the degree that you have taken it to will make a difference in being able to save your marriage.
Also, what does this have to do with ‘mommy issues’ as your title says?