The existing answers as of time of posting are incorrect as regards balloons, except in some cosmic sense tracking the energy of every particle through all of time.
For example: We expend 286 kJ to electrolyze 1 mole of water, put the mole of hydrogen gas in a massless 22L balloon, and float the balloon to a height of 5km. We have done just 100 J of work ($0.002 kg/mol \times 1 mol \times 5000m \times 10 m/s^2$). We then light it on fire. We'll get exactly 286 kJ of heat back, even though we've done 100 J of work. The hydrogen, now bound with new oxygen molecules, will eventually fall to the ground as rain, depositing the 100 J as extra heat. We can repeat this process as often as we want, gaining 100 J each time. Or we can truncate the process by igniting the balloon at 500m instead of 5000m, and only gain 10J each time - there's nothing special about the 100 J figure. If we had a magical indestructible infinitely stretchable massless balloon, the hydrogen would leave the planet and never come back, eventually reaching such distance that the gravitational potential energy is nearly that corresponding to infinite distance, because of the inverse square dependence of gravitational force. This would be just 125 kJ of gravitational potential energy ($0.5 \times .002 kg \times {v_e}^2$). If we remove the balloon envelope in the depths of interstellar space and wait a few billion years, the gas will disperse and will eventually combine with oxygen molecules, and we'll get our 286 kJ back.
This entirely variable amount of extra energy comes from the gravitational potential energy of the surrounding fluid, which descends, filling the volume left by the ascending buoyant object. This is similar to how the counter-weight on an elevator cable provides most of the energy required to lift the elevator car. It has nothing to do with the energy required to gather the material together.