This paper investigates GRB 050802, one of the best examples of a Swift gamma-ray burst afterglow that shows a break in the X-ray light curve, while the optical counterpart decays as a single power law. This burst has an optically bright afterglow of 16.5 mag, detected throughout the 170-650 nm spectral range of the Ultraviolet and Optical Telescope (UVOT) onboard Swift. Observations began with the X-ray Telescope and UVOT telescopes 286 s after the initial trigger and continued for 1.2 x 10(6) s. The X-ray light curve consists of three power-law segments: a rise until 420 s, followed by a slow decay with alpha= 0.63 +/- 0.03 until 5000 s, after which, the light curve decays faster with a slope of alpha(3)= 1.59 +/- 0.03. The optical light curve decays as a single power law with alpha(O) = 0.82 +/- 0.03 throughout the observation. The X-ray data on their own are consistent with the break at 5000 s being due to the end of energy injection. Modelling the optical to X-ray spectral energy distribution, we find that the optical afterglow cannot be produced by the same component as the X-ray emission at late times, ruling out a single-component afterglow. We therefore considered two-component jet models and find that the X-ray and optical emission is best reproduced by a model in which both components are energy injected for the duration of the observed afterglow and the X-ray break at 5000 s is due to a jet break in the narrow component. This bright, well-observed burst is likely a guide for interpreting the surprising finding of Swift that bursts seldom display achromatic jet breaks.