The fungus gnat Bradysia difformis Frey not only attacks edible and medicinal fungi, it also causes the damages to leek, green onion, garlic and other vegetable crops. To confirm the effects of temperature and sex ratio on adult fecundity, longevity and egg hatchability of B. difformis, we assayed the adults survival longevity and numbers of oviposition, as well as egg hatching rate under female-male ratios of 1:1, 1:2, 1:3, 2:1 and 3:1 at 10, 15, 20, 25 and 30°C. Female fecundity and egg hatchability were increased with temperature and peaked at 25°C, which, however, were adverse to adult longevity. Furthermore, female-male ratio of 1:1, 1:2 and 1:3 seemed suitable for female fecundity, of which the sex ratio of 1:1 was the most suitable ratio for its oviposition behavior. These results provide an insight for predicting the population density of B. difformis and offer a literature reference in the effective treatment of harmful insects by controlling and changing the sex ratio artificially.