Wow, this is a tough one.
I'd say "Here you go" is used when you are doing something for someone else. If you are not performing some action, use "there you go."
E.g.:
Customer in a restaurant orders coffee and cake. A waiter might bring the coffee and cake and say "Here you go."
A child is sick and staying home for the day. The child's mother brings him or her soup, a blanket, and a remote control for the tv and can say, "Here you go."
Compare:
A patient just had a cast removed from their leg. They're receiving physical therapy. The doctor watches as the patient starts walking on their own and to encourage the patient the doctor says, "There you go."
Someone loses a wallet. They're searching frantically for it and just when they give up hope, they find it under a chair. You could say, "there you go".
But note:
A kid falls down and scrapes their knee. Their father cleans the wound, puts on a bandage and says, "there you go, that wasn't so bad, was it?"
So there's some overlap between the too...