He showed me that there was a lot of pitch coming from the tree. He even opened a ball of pitch and showed me the worm inside it. He told me that I had to have the tree sprayed or the borers would kill it. Based on the description of the worm, spraying was probably not necessary.
Pitch is used to close wounds in the bark to prevent water loss.
Wind cracks caused when the tree bends and twists in the wind are sources of pitch. Insect attacks also stimulate pitch production. If an insect is involved, especially the one you probably saw, the pitch will probably have a yellowish or pinkish color. If it is due to wind or growth cracks in the bark, the pitch will first be crystal clear, drying to a frosty white, and with age turning brownish. Some of the pitch you saw was probably due to cracks in the bark, but there was obviously an insect involved as you saw one dug from the pitch.