Ophiocordyceps sinensis (Berk.) is a complex is formed by Hepialidae larvae and Hirsutella sinensis. Infestation by H. sinensis, interaction with host larvae, and fruiting body development are three crucial processes affecting the formation of O. sinensis. However, research on the molecular mechanism of O. sinensis formation has been hindered by the lack of effective genetic transformation protocols. Therefore, Agrobacterium tumefaciens-mediated transformation (ATMT) was adopted to genetically transform two H. sinensis strains and optimize the transformation conditions. The results revealed that the most suitable Agrobacterium strain for H. sinensis transformation was AGL1, and that the surfactant Triton X-100 could also induce ATMT, although less effectively than acetosyringone (AS). In addition, the endogenous promoters of H. sinensis genes had a stronger ability to drive the expression of the target gene than did the exogenous promoter. The optimal transformation conditions were as follows: AS and hygromycin B concentrations of 100 μM and 50 μg/mL, respectively; A. tumefaciens OD600 of 0.4; cocultivation at 18 °C for 24 h; and H. sinensis used within three passages. The results lay a foundation for the functional study of key regulatory genes involved in the formation of O. sinensis.