MERLIN maps of OH 1665- and 1667-MHz masers in the source G34.3+0.2 are presented. The majority of the OH masers lie in a parabolic arc along the eastern edge of the cometary H II region G34.3+0.2C, possibly tracing a bow shock. The OH masers lie systematically closer to the cometary HII region than the H2O masers, suggesting that OH is formed by dissociation of H2O in the shock. The remaining OH masers cluster around the ultracompact HII region G34.3+0.2B. Zeeman splitting indicates a magnetic field strength of typically -5 mG (directed towards us). A complex magnetic field structure is inferred from the maser polarization. Linear polarization is detected in half of the masers, at levels up to 85 per cent. The linear polarization vectors suggest that the magnetic field in some regions near the cometary HII region is perpendicular to the curved edge of the bow shock.