In the Jewish tradition (and later in the Catholic tradition) it was forbidden to pronounce God's name. Since there is a commandment that says that the name of God should not be pronounced in vain. Since the pronunciation of God's name was lost, they decided that it was also offensive to say the word "God" as an exclamation. So, in order to avoid saying the word "God" in the exclamation "oh my God!" they say "oh my Gosh!", which is basically the same when they change a letter in other expressions to make the sound nicer. For example "hell" for "heck", "holly shit" for "holly cow", "this fucking job" for "this f-ing job", and so on.