A bird can be stopped from pecking on an outside window by breaking up the reflection that can be seen from the outside of the glass. This can be done by affixing decals on the window, placing strips of plastic tape on the window or by soaping the outside of the window.
Birds are territorial and will attack their reflection when they assume it is a rival bird. Other ways to stop a bird from pecking outside glass on a house is by placing a nonreflective screen about 2 to 3 inches away from the glass. A one-way transparent film or opaque plastic can also be installed.