So, to rephrase your question (for the sake of my answer, not because you were unclear): Of the two determinants of pronoun choice (natural sex versus grammatical gender of referent noun), which one 'wins'? One rule that I have been told is that if the child's name has been used and even if the name is not sex-specific, then you are entitled henceforth to use the corresponding gender pronoun. E.g.
Das Baby heißt Peter. Er ist 6 Monate alt.
I suppose this works because the masculine pronoun is understood to refer to the name (in this instance "Peter") rather than to the noun das Baby. The same is true of other neuter nouns that refer to people like das Kind and das Mädchen.
It's possible the same thinking applies if the baby is known to the persons involved in the conversation to be of one sex or the other, even if the name isn't used. For example, if two friends meet up and the one asks the other "Wie geht's dem Baby?", it might be acceptable to respond with a male or female pronoun because the sex of the baby to which the noun refers is known and, in a sense, overrides the purely linguistic consideration. But that's just speculation, I can't say for sure, because my German friends have only recently started having babies and I've not yet had occasion to ask or be corrected.
For a very dramatic example relevant to this topic, I've just been watching an episode of Tatort (here). At 1:24:57 the detective says to the man who's threatening to jump off the roof with his daughter: "Aber das da ist Ihr Kind. Das hat Sie lieb!" So even though the sex of the child is obvious to all present, the gender of the noun seems to override the natural sex. But this is only one example.