This really sounds behavioral, having to do with status. He is neutered? He could be upset you are giving your friend attention he feels entitled to. Perhaps she unintentionally sent a message she outranks him and he was showing her who is top dog. I hate to fall back on no better than suggesting obedience training, but it could help. The dogs see all the
people and dogs in the household as a pack with each having their own rank in
the pack and a top dog. Life is much easier if the 2 legged pack members
outrank the 4 legged ones. You can learn to play the role of top dog by
reading some books or going to a good obedience class. A good obedience class
or book is about you being top dog, not about rewarding standard commands with
a treat. Start at
http://www.dogsbestfriend.com/. You may want to consider some stern discipline if it starts to become a pattern. Get back with me.