Why did Reverend Hooper say he wore the black veil over his face to preach his sermon?
In short, he doesn't. Mr. Hooper does not say why he's put on the veil before he delivers his sermon, and he really never totally explicitly states its purpose after the sermon either. The subject of the sermon, however, is our first (and his congregation's first) clue: it "had reference to secret sin, and those sad mysteries which we hide from our nearest and dearest, and would fain conceal from our own consciousness, even forgetting that the Omniscient can detect them." In other words, then, the sermon discusses the idea that each of us has secret sins for which to account, but we attempt to hide this sinfulness even from our loved ones. We would even prefer to allow ourselves to forget and to believe that God is unaware of these secret sins. Thus, we can begin to understand that the veil represents this desire and the attempt to hide our true natures, our sinful natures, from the world.
Mr. Hooper says something similar at the story's end, when he's on his deathbed. He says, "'When the friend shows his inmost heart to his friend; the lover to his best beloved, when man does not vainly shrink from the eye of his Creator, loathsomely treasuring up the secret of his sin; then deem me a monster, for the symbol beneath which I have lived, and die!'" He describes the veil, explicitly, as a symbol of this secrecy we all hope to maintain: from our friends, ourselves, our god. We hide our real selves by pretending that we are not sinful, and Mr. Hooper has worn the veil as a tangible symbol of this invisible attempt to hide.