When you say "Sorry", you are apologizing for some action. In other words, you regret that you are leaving. "Excuse me", is a very polite gesture to excuse yourself from an establishment. For example, if you were talking with other adults in a group, but you realized that it was getting late and you had to leave, you would politely interrupt the conversation and say, "Excuse me, I have to leave now." It can also be a polite way of removing yourself from unwanted conversation. Basically, "Sorry" conveys regret, and "Excuse me" conveys an actual desire to leave.