Selaginella doederleinii (SD) is a perennial medicinal herb widely distributed in China. In this study, the volatile components of SD from two regions (24 batches), namely Zhejiang and Guizhou, were determined by combining headspace solid phase microextraction and gas chromatography-mass spectrometry (HS-SPME/GC-MS). After investigating different influence factors, the optimal conditions for extraction were as follows: The sample amount of 1 g, the polydimethylsiloxane-divinylbenzene (PDMS-DVB) fiber of 65 µm, the extraction time of 20 min, and the extraction temperature of 100 °C. Based on the above optimum conditions, 58 volatiles compounds, including 20 terpenes, 11 alkanes, 3 alcohols, 6 ketones, 3 esters, 11 aldehydes, 1 ether, 1 aromatic, 1 phenol, and 1 furan, were found and identified in SD. Furthermore, hierarchical cluster analysis and principal component analysis were successfully applied to distinguish the chemical constituents of SD from two regions. Additionally, anethol, zingerone, 2,4-di-tert-butylphenol, ledene, hexyl hexanoate, α-cadinol, phytone, hinesol, decanal, octadecene, cedren, 7-tetradecene, copaene, β-humulene, 2-butyl-2-octenal, tetradecane, cedrol, calacorene, 6-dodecanone, β-caryophyllene, 4-oxoisophorone, γ-nonanolactone, 2-pentylfuran, 1,2-epoxyhexadecane, carvacrol, n-pentadecane, diisobutyl phthalate, farnesene, n-heptadecane, linalool, 1-octen-3-ol, phytane, and β-asarone were selected as the potential markers for discriminating SD from 24 habitats in Zhejiang and Guizhou by partial least squares discrimination analysis (PLS-DA). This study revealed the differences in the components of SD from different regions, which could provide a reference for the future quality evaluation.