So, the wax's gravity is greater than 1, therefore, heavier than water. But when the wax gets hot, it gets lighter, or less dense. Then, it floats, because the gravity becomes less than one.
BUT, when the wax floats, it also gets further away from the heat source. Therefore, it cools off, and it's gravity becomes greater than 1. So, it sinks! And the process repeats.