Is there a set phrase for being polite to a person only when they are present?

Solution 1:

If your audience consists of those conversant with classic American television, this type of behavior could be described as being a regular Eddie Haskell (or "acting like Eddie Haskell"). Eddie Haskell is an archetypal character from the classic early TV show "Leave It To Beaver" whose defining characteristic was exactly the type of behavior you describe.