The Code of Military Conduct allows for them to open his retirement, demote him, and decrease his retirement for his infidelity. I think that if any member of the armed forces was demoted, or stripped of retirement or salary benefits because of similar infiedility, then Petraeus needs to as well.
As to whether Obama knew, I think someone in the White House knew, but I have a feeling Obama is a very detached leader. Misses over half the daily intelligence briefings, doesn’t meet even with his own party members of Congress. I think he leaves most of the decision making in the WH to others. Sad, but I’m afraid, true.