The rules are a little vague on the matter and Sage Advice doesn't seem to offer any help, either. However, lead rules Jeremy Crawford has weighed in on this kind of issue several times in an unofficial capacity:
Does Charm Person spell ends if Polymorph is cast on the charmed humanoid? Or does Polymorph suppress the spell called Charm Person until the human form returns?
There's no rule governing what happens when a valid spell target temporarily becomes an invalid target. A good rule of thumb is that the spell is suppressed while the target is invalid. #DnD
So a druid under the effect of Dominate Beast reverts and is still dominated that makes perfect sense....
[Here Crawford contradicts the logic of the statement above, thereby confirming the message of the first tweet:] In #DnD, the exceptional trumps the general. (No longer being a valid target trumps condition carryover.)
The combination of these tweets suggests that if a target of an effect stops becoming a valid target for that effect (eg, animated objects becoming creatures are no longer considered "objects" for heat metal), then the initial effect is at least suppressed for the duration that the entity is not a valid target.
Situationally, it may make more sense for the spell/effect to simply end (or some other result). Ultimately, it falls to the DM.