As a general rule, I'd say commas are used in place of exclamation marks - i.e. when the "Oh" or "Ah" are being used as exclamations: Oh! I forgot my keys! Ah! Now I understand! Oh, I forgot my keys! Ah, now I understand! In contrast, commas look very out of place where the "Oh" or "Ah" is part of a flat idiom: Oh my gosh! Oh my God!?Oh, my gosh! More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.