Isaria cicadae is one of the fungi used in traditional Chinese medicine with the longest tradition. It is used not only as a herbal medicine but also as a health food in Asia, together with cultured cordyceps and mycelia of the fungus used as substitute. However, the differences in their metabolite are unknown. Using a high‐performance liquid chromatography–mass spectrometry (HPLC–MS)‐based metabolomic method, we found that the fungus varies in its metabolism during growth on wild insects, artificially raised insects and artificial medium. There were 109 discriminatory metabolites detected in the samples by orthogonal projection to latent structure discriminant analysis and one‐way ANOVA. High level of nonribosomal peptides (NRPs) only existed in the insect portions of the wild cordyceps (WI) and cultured cordyceps (CI), revealing that immunostimulation of the host insects enhanced the synthesis of NRPs in the fungus. The finding of a significantly higher level of sphingolipids in both the insect portions (WI, CI) and the coremia of the wild cordyceps (WC) and cultured cordyceps (CC) but not in cultured mycelia (CM) of I. cicadae implies that the immunostimulation of the live insects can induce the fungus to produce more sphingolipids, and this enhanced ability is probably heritable. Apart from NRPs and sphingolipids, the insect portions also contained higher levels of bioactive compounds such as lateritin, anisomycin, streptimidone and ustiloxins. In contrast, the coremium groups (WC, CC) and CM contained 10‐fold less NRP but much higher levels of sanative metabolites such as tocotrienol, 3′‐deoxy‐hanasanagin, γ‐aminobutyric acid and phospholipids than the insect portions. The significantly higher content of antioxidants in WC, CC and CM than in WI and CI suggests that environmental oxygen has a significant effect on the metabolites. The temperature stress which the wild cordyceps encounters during growth is responsible for the relatively high content of trehalose. These findings indicate that the immunity of the host insect and growth environment have a strong impact on the metabolomic variation in Isaria cicadae. The variation in metabolites suggests differential utilization value for the insect portions, coremia and mycelia of the fungus.