Woodpeckers peck wood for several reasons, primarily to search for small tree-boring insects to eat or to create a nesting site. A woodpecker also pecks wood in a rhythmic, rapid succession in order to establish its territory and attract a mate.
A woodpecker that is pecking in rhythmic succession is said to be "drumming." Though this usually occurs on trees, woodpeckers like to drum on other resonant surfaces such as TV antennas, drain pipes, rain gutters and plumbing vents. Some woodpeckers, called sapsuckers, peck at trees in order to get to the sap they enjoy eating. Usually, a sapsucker selects several favorite trees and drills many holes inside of those while leaving nearby trees untouched.