Many volatile compounds generated during the thermal processing of milk have been associated with cooked, stale, and sulfurous notes in milk and are considered as off-flavor by most consumers. A headspace solid-phase microextraction (HS-SPME)/gas chromatographic technique for the quantitative analysis of thermally derived off-flavor compounds was developed in this study. The extraction temperature, time, and sample amount were optimized using a randomized 2(3) central composite rotatable design with 2 central replicates and 2 replicates in each factorial point along with response surface methodology. Calibration curves were constructed in milk using the standard addition technique, and then used to quantify 20 off-flavor compounds in raw, pasteurized, and UHT milk samples with various fat contents. The concentrations of these volatiles in raw and pasteurized milk samples were not significantly different. However, dimethyl sulfide, 2-hexanone, 2-heptanone, 2-nonanone, 2-undecanone, 2-methylpropanal, 3-methylbutanal, heptanal, and decanal were found at higher concentrations in UHT milk as compared with raw and pasteurized milk samples. In addition, the concentration of methyl ketones was greater in UHT milk with higher fat content. The calculated odor activity values suggested that 2,3-butanedione, 2-heptanone, 2-nonanone, 2-methylpropanal, 3-methylbutanal, nonanal, decanal, and dimethyl sulfide could be important contributors to the off-flavor of UHT milk. The HS-SPME technique developed in this study is accurate and relatively simple, and can be used for the quantification of thermally derived off-flavor compounds in milk.