According to Mythbusters, the eyes close just before a sneeze due to a reflex action as the eyes and the nose are connected by cranial nerves. The sneeze sends a stimulation that travels to a nerve in the brain and a nerve in the eyelids triggering the eyes to close.
According to LiveScience, sneezing is a way in which the body protects the nasal passages from foreign particles. Air is forced out of the area of the lungs, and the brain orders the muscles to contract from the esophagus all the way to the sphincter. These orders include the muscles that control the eyelids. Certain sneezes can even cause the eyes to shed tears.