The effects of transcranial magnetic stimulation in treating substance use disorders are gaining attention; however, most existing studies used subjective measures to examine the treatment effects. Objective electroencephalography (EEG)-based microstate analysis is important for measuring the efficacy of transcranial magnetic stimulation in patients with heroin addiction. We investigated dynamic brain activity changes in individuals with heroin addiction after transcranial magnetic stimulation using microstate indicators. Thirty-two patients received intermittent theta-burst stimulation (iTBS) over the left dorsolateral prefrontal cortex. Resting-state EEG data were collected pre-intervention and 10 days post-intervention. The feature values of the significantly different microstate classes were computed using a K-means clustering algorithm. Four EEG microstate classes (A–D) were noted. There were significant increases in the duration, occurrence, and contribution of microstate class A after the iTBS intervention. K-means classification accuracy reached 81.5%. The EEG microstate is an effective improvement indicator in patients with heroin addiction treated with iTBS. Microstates were examined using machine learning; this method effectively classified the pre- and post-intervention cohorts among patients with heroin addiction and healthy individuals. Using EEG microstate to measure heroin addiction and further exploring the effect of iTBS in patients with heroin addiction merit clinical investigation.