The molecules at the bottom of the mug gain energy and spread out as a result. This means that these molecules are less dense than the ones above them so they rise upwards. As they do so, they lose energy to their surroundings, become cooler and more dense so they fall back downwards through the coffee to repeat the cycle.