UNIT_PET fires whenever you gain/lose/change a pet. So you could use that in conjunction with the
UnitExists("pet") function.
edit: or the frame could be parented to the pet frame, which would make it show/hide if the pet frame is shown/hidden. This would make it difficult to support numerous unit frame addons, however.