Interacting selectively and non-covalently with DNA containing a hairpin. A hairpin structure forms when a DNA strand folds back on itself and intrachain base pairing occurs between inverted repeat sequences.