How energy is released when chemical bond is formed?
Let us assume the simplest case to form a bond from two atoms (assumed to be in their ground state) that approach each other from an infinite distance. For convenience, we put the potential energy of the system at zero here. If the atoms come closer, they start to interact via long-range forces (such as van der Waals forces) and the potential energy is slightly lowered. If the atoms come even closer, their wave functions start to overlap and the potential is reduced rather steeply as compared to the long-range forces. Moving the atoms even closer increases the potential as the electrons will start to repel each other. The potential energy as a function of the interatomic distance can be approximately described by a Morse potential (the blue curve in the figure below (taken from Wikipedia))



In the figure you also see horizontal lines in the Morse potential which represent the energies of the vibrational states that are supported by the potential. Now that we know what the potential looks like we can take our two atoms at infinite distance and move them towards each other, that is, the total energy $E_\text{tot}(r)=E_\text{Morse}(r)+E_\text{kin}(r)&gt;0$. As the atoms get closer, the potential energy gets lower and the velocity and kinetic energy increase, the total energy is - of course - conserved. When the atoms come so close that they start to repel each other (when they hit the repulsive "wall" on the left), they fly away in opposite direction and end up at infinity again! This is the same result that you would find with an ideal marble track (no friction) that is similarly shaped to the Morse potential: the marble will roll down, first accelerate, then climbs up the wall on the left and rolls back to where it started. In order to from a bond (or to stop the marble in the middle) we need to remove part of the energy of the system. As Ivan Neretin pointed out, this can be done by emitting a photon. When the atoms are separated at $r_e$, the release of a photon with energy $h\nu=D_0+E_\text{kin}$ will result in a loss of energy and the atoms will be trapped in the potential. (In our marble track, friction can play a similar role)

This process is called radiative association and it is believed that it played an important role in the chemistry of the early Universe. However, not all molecules can emit a photon. There are some rules - selection rules - which have to be fulfilled. The molecule needs to have a dipole moment for instance. Therefore $\text{H}_2$ molecules are unlikely to be formed via radiative association. 

Another, more likely, method to remove the energy is to have a third atom (or molecule) colliding with the other two atoms. This atom can then take away the excess energy in the from of kinetic energy in a so-called three-body collision. 

When you have more complex molecules that collide to form bonds, the excess energy can be distributed over the different degrees of freedom that the molecule possesses. For instance, the molecule's vibrational and/or rotational energy is increased which results in an increase in temperature.