Although commensal bacteria are crucial in maintaining immune homeostasis of the intestine, the role of commensal bacteria in immune responses at other mucosal surfaces remains less clear. Here, we show that commensal microbiota composition critically regulates the generation of virus-specific CD4 and CD8 T cells and antibody responses following respiratory influenza virus infection. By using various antibiotic treatments, we found that neomycin-sensitive bacteria are associated with the induction of productive immune responses in the lung. Local or distal injection of Toll-like receptor (TLR) ligands could rescue the immune impairment in the antibiotic-treated mice. Intact microbiota provided signals leading to the expression of mRNA for pro-IL-1β and pro-IL-18 at steady state. Following influenza virus infection, inflammasome activation led to migration of dendritic cells (DCs) from the lung to the draining lymph node and T-cell priming. Our results reveal the importance of commensal microbiota in regulating immunity in the respiratory mucosa through the proper activation of inflammasomes.