There are three main reasons that woodpeckers peck on wood; one, they're looking for something to eat, two, they're defining their territory and three, they are making a nest. It's usually the second reason that creates the most damage.
Woodpeckers are very territorial. In order to let other woodpeckers know that this is his (or in some cases her) territory, it flies around the perimeter of its territory, usually in the morning, and initiates a series of raps on hollow trees or other wood members that have the “right” sound. This behavior is called “drumming” and consists of two or three long brrrrrrrrrrrps. The woodpecker will typically drum in one spot for a minute or so, day after day. It does not take long before a large, irregular hole appears at the drumming site. If the site is a log or siding of a home, it can become a real eye sore.
When a woodpecker pecks for grubs in wood it acts differently and makes smaller cone shaped holes or a long gallery. If you have ever seen a woodpecker searching for grubs it will constantly turn its head as if looking for something on the wood. It is actuality listening for grubs feeding in the wood. All it needs to do is make a hole large enough for its
tongue. A woodpecker's tongue is long and thin and that's what it uses to catch a grub in a gallery. The holes woodpeckers make searching for grubs are usually no more than an inch or so in diameter. Occasionally a woodpecker will attempt to excavate out a round nesting hole in a log, but it's rare and if the wood is sound it will usually give up after a few days. However, they will make a hole in synthetic chinking to establish a nesting site.
Solving the Problem
One thing you can try to discourage drumming woodpeckers is to put a piece of metal window screen over the area where the woodpecker drums. This often discourages it enough that it will go elsewhere. Fake owls, snakes and other scare devices may work for a little while but it does not take very long for the woodpecker to discover that if it just ignores it, nothing happens. Trapping and releasing woodpeckers does not do much good either. They can fly and unless you release them many miles away, they'll return to their home territory within a few days.
For woodpeckers feeding on beetle grubs, the best solution is to kill the grubs in the wood and the way to do that is to treat the wood with a borate. This will kill the beetle larvae and if there are no grubs for the woodpecker to search for, it will move on to better feeding sites. However, borates are not effective for eliminating or preventing carpenter bees so other methods of control must be used.