OH is an important molecule in the H2O chemistry and the cooling budget of star-forming regions. The goal of the Herschel key program `Water in Star-forming regions with Herschel (WISH) is to study H2O and related species during protostellar evolution. Our aim in this letter is to assess the origin of the OH emission from star-forming regions and constrain the properties of the emitting gas. High-resolution observations of the OH 2Pi1/2 J = 3/2-1/2 triplet at 1837.8 GHz (163.1 micron) towards the high-mass star-forming region W3 IRS 5 with the Heterodyne Instrument for the Far-Infrared (HIFI) on Herschel reveal the first hyperfine velocity-resolved OH far-infrared spectrum of a star-forming region. The line profile of the OH emission shows two components: a narrow component (FWHM approx. 4-5 km/s) with partially resolved hyperfine structure resides on top of a broad (FWHM approx. 30 km/s) component. The narrow emission agrees well with results from radiative transfer calculations of a spherical envelope model for W3 IRS 5 with a constant OH abundance of approx. 8e-9. Comparison with H2O yields OH/H2O abundance ratios of around 1e-3 for T > 100 K and around unity for T < 100K, consistent with the current picture of the dense cloud chemistry with freeze-out and photodesorption. The broad component is attributed to outflow emission. An abundance ratio of OH/H2O > 0.028 in the outflow is derived from comparison with results of water line modeling. This ratio can be explained by a fast J-type shock or a slower UV-irradiated C-type shock.