This is the standard way to say “sorry” in Japanese, and you can use it in most situations. ごめんなさい (gomen nasai) is the polite way to say “I'm sorry,” but you can make it more casual, too. Switching it to ごめん (gomen, masculine) or ごめんね (gomen ne, feminine) makes it more casual and lighthearted for minor issues.