In most magnetically-ordered iron pnictides, the magnetic moments lie in the FeAs planes, parallel to the modulation direction of the spin stripes. However, recent experiments in hole-doped iron pnictides have observed a reorientation of the magnetic moments from in-plane to out-of-plane. Interestingly, this reorientation is accompanied by a change in the magnetic ground state from a stripe antiferromagnet to a tetragonal non-uniform magnetic configuration. Motivated by these recent observations, here we investigate the origin of the spin anisotropy in iron pnictides using an itinerant microscopic electronic model that respects all the symmetry properties of a single FeAs plane. We find that the interplay between the spin-orbit coupling and the Hunds rule coupling can account for the observed spin anisotropies, including the spin reorientation in hole-doped pnictides, without the need to invoke orbital or nematic order. Our calculations also reveal an asymmetry between the magnetic ground states of electron- and hole-doped compounds, with only the latter displaying tetragonal magnetic states.