Take it to the underground area near the coastal city mentioned in the original answer. There is a character down there who will trade you TM Explosion for the candy bar.
Explosion is a spectacularly powerful move, so the swap is well worth making — just do not use it on a Pokémon you were planning to keep.