Energy concentration and loss due to a violent collapsing bubble are essential phenomena to many applications such as cavitation erosion, biomedical ultrasonics, sonochemistry, cavitation cleaning and underwater explosions. It has been generally known that the energy of a bubble system is radiated away as an acoustic wave and dissipated by viscosity. However, there is no study in the scientific literature on the time history of the energy of a bubble system in a compressible flow. Here we have introduced the local energy of a non-spherical bubble system, consisting of the energy of the interior gas, the interface and the exterior liquid in the inner asymptotic region. The local energy determines the local bubble and flow dynamics, including the concentration of energy, stress and momentum. We obtain a simple formula for the radiated energy associated with acoustic radiation in terms of the bubble volume history. We perform calculations of the energy history for a transient bubble in a compressible liquid in an infinite domain, subject to buoyancy and near a rigid boundary, respectively. Our calculations show that the local energy of a transient bubble follows a step function in time, being nearly conserved for most of each cycle of oscillation but decreasing rapidly and significantly at bubble inception and at the end of collapse, due to the emission of steep pressure waves or shock waves. The loss of the local energy of the bubble system due to the emission of steep pressure waves and the associated damping of the bubble oscillation are diminished by buoyancy effects and decrease with the buoyancy parameter. Similarly, the loss of the local energy of a bubble system is diminished by the presence of a rigid boundary and decreases with the proximity of the bubble to the boundary. We also analyse the energy concentration of single bubble sonoluminescence in a standing acoustic wave.