Our noses are designed to repel anything that enters except air. Its three main defences are the fine nasal hairs in the nostrils, mucus and sneezes – reflex actions caused when nerve endings in the mucus membranes are irritated. Any rush of particles (eg dust) may trigger sneezes, but pepper is particularly irritating due to the substance that gives pepper its flavour. Piperine is an alkaloid that stimulates the nasal nerve endings, causing the brain to trigger muscles in the nose and throat to expel the foreign particles in a sudden burst of air.
Answered by Mike Anderiesz, How It Works contributor.