I am a former barista who has encountered this phenomena many times, but could never consistently re-produce the effect.
Heavy cream should be lightly whipped, still in a somewhat pourable state. If it is over-whipped, it will have more of a tendency to sink.
The beverage should be at least slightly sweetened with white sugar or brown sugar. The dissolved sugar in the beverage will help to keep the cream afloat.
So, the problem could be over-whipped cream, no sugar, or both. Inconsistencies in either of those areas may be why your results varied.
Lastly, I have always been told that unwhipped or whipped heavy cream should be poured gently over the back of a warm spoon. That is supposed to ensure a gentle addition of the cream around the sides of the cup/glass that will make it float. (It's a useful technique for adding the cream.) I have seen many people do this, but I have always been successful without using a spoon.