To explore the interaction between emotional and insomnia symptom improvement in comorbid depression and insomnia patients treated with optimized acupuncture. A secondary analysis was conducted on a multicenter randomized controlled trial of acupuncture treatment for comorbid depression and insomnia. One hundred and forty patients with comorbid depression and insomnia were randomly assigned to an optimized acupuncture group (70 cases, 8 cases dropped out) and a conventional acupuncture group (70 cases, 8 cases dropped out). The patients in the conventional acupuncture group were treated with acupuncture at Yintang (GV 24+), Baihui (GV 20), bilateral Hegu (LI 4) and Taichong (LR 3); the patients in the optimized acupuncture group were treated with additional acupuncture at bilateral Lieque (LU 7), Zhaohai (KI 6), and intradermal needling was applied alternately at bilateral Xinshu (BL 15) and Danshu (BL 19), Shenshu (BL 23) and Anmian (Extra). Both groups received treatments twice a week for six weeks. The Hamilton depression scale-24 (HAMD-24) and Pittsburgh sleep quality index (PSQI) scores were observed before and after treatment for both groups. Mediation analysis was used to assess the mesomeric effect of PSQI and HAMD-24 emotional factors, and latent profile analysis categorized patients into subgroups based on HAMD-24 scores, followed by between-group efficacy comparisons. The indirect effect of the optimized acupuncture on improving depression emotions through PSQI was 3.052 (95%CI [1.407, 4.697]), accounting for 77.5% of the total effect. Conversely, the indirect effect of improving PSQI through the optimized protocol on depression emotions was 0.479 (95%CI [0.024, 0.935]), representing 14.8% of the total effect. Latent profile analysis identified 3 categories based on emotional and insomnia symptoms, and statistically significant differences in efficacy favoring the optimized acupuncture protocol over the conventional acupuncture protocol were observed only in the subgroup with relatively mild depression and insomnia symptoms (PSQI: 95%CI [-10.98, -5.44], P<0.001; HAMD-24: 95%CI [-12.31, -3.73], P =0.001). The optimized acupuncture protocol primarily improves insomnia symptoms and further improves depression emotions. Its efficacy advantages are more evident in patients with mild symptoms compared with the conventional acupuncture protocol.