Distribution of energy dissipated by a driven two-level system