"treat as a pet;" the sense of "to stroke" is first found 1818. Slang sense of "kiss and caress" is from 1920 (implied in petting, in F. Scott Fitzgerald). Teacher's pet is attested from 1914.
pet"peevishness, offense at feeling slighted," 1590, in phrase take the pet "take offense." Perhaps from pet (1) on a similar notion to that in Amer.Eng. that gets my goat, but the underlying notion is obscure, and the form of the original expression makes this doubtful. This word seems to have been originally
a southern Eng. term, while pet (1) was Scottish.