This is an expression that people use when they're shocked or surprised. It can be used with friends or with people you don't know.
Serious, adult English speakers use "Oh my God!" when something is really shocking or surprising. For example, if your friend tells you that she got fired, you should say "Oh my God!" But a lot of young people (especially girls) also use this phrase for small and trivial things. A teenager might say "Oh my God!" when she sees that her friend is wearing a cute outfit.
Although the phrase has the word "God" in it, it's so common that most people don't associate it with religion. So you can use it whether you're religious or not. There are a small number of religious people who don't use this phrase because it has the word "God" in it, so you may want to keep that in mind if you know very religious people.