Meaning: A person who is not known to the dog is showing affection to it by touching its head in a soft and careful way.
Choice of Words: Stranger is a person who is not known or familiar. Pets means to touch or stroke an animal affectionately. Gently means in a soft and careful manner. On is used to show the position or location of something. Head is the part of an animal's body that contains the brain.