Cereal vinegar is usually produced through solid-state fermentation, and the microbial community plays an important role in fermentation. In this study, the composition and function of Sichuan Baoning vinegar microbiota at different fermentation depths were evaluated by high-throughput sequencing combined with PICRUSt and FUNGuild analysis, and variations in volatile flavor compounds were also determined. The results revealed that no significant differences (p > 0.05) were found in both total acid content and pH of vinegar Pei collected on the same day with different depths. There were significant differences between the bacterial community of samples from the same day with different depths at both phylum and genus levels (p < 0.05), however, no obvious difference (p > 0.05) was observed in the fungal community. PICRUSt analysis indicated that fermentation depth affected the function of microbiota, meanwhile, FUNGuild analysis showed that there were variations in the abundance of trophic mode. Additionally, differences in volatile flavor compounds were observed in samples from the same day with different depths, and significant correlations between microbial community and volatile flavor compounds were observed. The present study provides insights into the composition and function of microbiota at different depths in cereal vinegar fermentation and quality control of vinegar products.