The antibacterial effect and mechanism of ozone (O3) treatment on freshly-peeled garlic inoculated with Gibberella intermedia (G. intermedia) and Aspergillus ochraceus (A. ochraceus) in different conditions were studied in vivo. The results showed that the specific O3 concentration, treatment time, and humidity significantly affected the garlic's indexes. The optimal treatment conditions of garlic inoculated with both molds were 6 ppm, 15 min, and 90%, respectively. After treatment with those conditions, the incidence etc of garlic were significantly reduced during storage. Differential analysis was performed for the RNA-sequencing and gene expression of the molds subjected to O3 treatment, as well as the samples that were not. The results showed that O3 treatment inhibited the growth of G. intermedia and A. ochraceus. Consequently, 2754 and 2378 differentially expressed genes, 1456 and 1591 up-regulated genes, and 1298 and 787 down-regulated genes were screened, respectively, for these molds, affecting the catalytic activity and various other pathways.