The denitrification occurs at the roots because they are what is used to feed the plant itself. Nitrogen is the base chemical used for plant growth, the absences of it and plants do not grow. The bacteria work in a symbiotic relationship with the plant.
"The symbiotic nitrogen-fixing bacteria invade the root hairs of host plants, where they multiply and stimulate formation of root nodules, enlargements of plant cells and bacteria in intimate association. Within the nodules the bacteria convert free nitrogen to
ammonia, which the host plant utilizes for its development. To ensure sufficient nodule formation and optimum growth of
legumes (e.g., alfalfa, beans, clovers, peas, soybeans), seeds are usually inoculated with commercial cultures of appropriate
Rhizobium species, especially in
soils poor or lacking in the required bacterium."