"tamed animal," originally Scot. and northern England dial., of unknown origin. Sense of "indulged child" (1508) is recorded slightly earlier than that of "animal kept as a favorite" (1539), but the latter may be the primary meaning. Probably associated with or influenced by petty. The verb is 1629 meaning "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.
"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.