Exclusive electroproduction of ω mesons on unpolarized hydrogen and deuterium targets is studied in the kinematic region of Q2>1.0 GeV2, 3.0 GeV < W < 6.3 GeV, and -t'< 0.2 GeV2. Results on the angular distribution of the ω meson, including its decay products, are presented. The data were accumulated with the HERMES forward spectrometer during the 1996-2007 running period using the 27.6 GeV longitudinally polarized electron or positron beam of HERA. The determination of the virtual-photon longitudinal-to-transverse cross-section ratio reveals that a considerable part of the cross section arises from transversely polarized photons. Spin density matrix elements are presented in projections of Q2or -t’. Violation of s-channel helicity conservation is observed for some of these elements. A sizable contribution from unnatural-parity-exchange amplitudes is found and the phase shift between those amplitudes that describe transverse ω production by longitudinal and transverse virtual photons, γ∗L→ωT and γ∗T→ωT, is determined for the first time. A hierarchy of helicity amplitudes is established, which mainly means that the unnatural-parity-exchange amplitude describing the γ∗T→ωT transition dominates over the two natural-parity-exchange amplitudes describing the γ∗L→ωL and γ∗T→ωT transitions, with the latter two being of similar magnitude. Good agreement is found between the HERMES proton data and results of a pQCD-inspired phenomenological model that includes pion-pole contributions, which are of unnatural parity.