We use polarized inelastic neutron scattering to study the temperature and energy dependence of spin space anisotropies in the optimally hole-doped iron pnictide Ba0.67K0.33Fe2As2 (Tc = 38 K). In the superconducting state, while the high-energy part of the magnetic spectrum is nearly isotropic, the low-energy part displays a pronouced anisotropy, manifested by a c-axis polarized resonance. We also observe that the spin anisotropy in superconducting Ba0.67K0.33Fe2As2 extends to higher energies compared to electron-doped BaFe2−xT MxAs2 (T M =Co, Ni) and isovalent-doped BaFe2As1.4P0.6, suggesting a connection between Tc and the energy scale of the spin anisotropy. In the normal state, the low-energy spin anisotropy for optimally hole-and electron-doped iron pnictides onset at temperatures similar to the temperatures at which the elastoresistance deviate from Curie-Weiss behavior, pointing to a possible connection between the two phenomena. Our results highlight the relevance of the spin-orbit coupling to the superconductivity of the iron pnictides.