Food is prevented from entering the nasal cavity during swallowing by the uvula that is located at the end of the soft palates.
The soft palates are composed of 5 muscles. During swallowing the uvula and the soft palate elevated to block and isolate the nasal cavity from the mouth. When the soft palate rises it creates a vacuum in the mouth which prevents the food from entering the respiratory tract.