Two-dimensional atomic layer materials, as an important part of the post-Moore era, have recently become an ideal choice for the preparation of high-efficiency, low-power, and miniaturized gas sensors. In this work, our study utilized density functional theory and the nonequilibrium Green's function method to investigate the electronic properties of the pentagonal BN2 (P-BN2) monolayer, as well as its gas-sensing properties for organic and inorganic gases. We also investigated how defects affect the quantum transport properties of the P-BN2-based device. Our findings demonstrate that the CO, H2S, NH3, SO2, C2H5OH, C3H6OH, CH3OH, and CH4 undergo physisorption on the P-BN2 monolayer, while NO, NO2, C2H2, C2H4, and HCHO undergo chemisorption. Then, we analyzed the impact of gas molecules chemisorbed on the P-BN2 monolayer on the electronic transport properties of the P-BN2-based gas sensor. When these five gas molecules are adsorbed, the current of the P-BN2-based gas sensor is greatly reduced. In addition, the effect of defects on the quantum transport properties of the P-BN2-based device is investigated. The results indicate that defects of N, B, and BN atoms lead to a decrease in the current of P-BN2-based nanodevices. Moreover, both the adsorption of gas molecules and the formation of vacancy defects leading to a decrease in device current can be revealed by the local device density of states near the zero-bias Fermi level, elucidating their microscopic mechanisms. Finally, gas molecules can also cause a decrease in the current of defect systems. These theoretical studies are of great significance for exploring two-dimensional atomic layer materials as high-efficiency gas sensors.