I do not know of any Church doctrine interpreting this verse one way or the other concerning the proposition for which your friend cited it.
Remember that the Catholic way of reading Scripture is always to read in context–the context of the inspired author’s purpose, his audience, and the context of the surrounding verses and chapters, among other factors. (See the Conciliar document Dei Verbum for more on that topic.)
So prayerfully read the text not as a single verse torn from the fabric of the historical accounts of King David, but as part of that whole. Many of our separated brothers and sisters use single verses taken out of context as “proof” of various points of Protestant doctrine, but these proofs tend to fail when the verse in question is read IN context.
With that in mind, the first and perhaps most important point which seems clear to me is that whatever this verse says, it reflects only David’s opinion or understanding of where his son’s soul has gone after death. (This presumes, of course, that David even believed in the idea of the soul as taught by Christ and His Church. I am not enough of a scholar to tell you whether David’s particular brand of Judaism held that belief in his day.) The statement David makes does not purport to be a message from God, either directly or through one of the Prophets. Second, the only thing we can infer from this passage is that David appears to believe he will go wherever his son went when he himself dies. But it certainly does not state or even imply that this will necessarily be Heaven as we understand it. Thus for these reasons alone I would conclude that your friend has taken meaning from this verse which simply is not there.
Next, let’s look elsewhere in the accounts of David for additional guidance as to where he believed he would go when he died. One indication appears in 2 Sam 22: 5-6, where in the course of his great prayer of thanks after winning the battle with Saul and his army, David says:
"[5] “For the waves of death encompassed me,
the torrents of perdition assailed me;
[6] the cords of Sheol entangled me,
the snares of death confronted me.”
Here David equates death with Sheol, the place of the dead so frequently referenced in the Old Testament, especially in the Psalms (many of which traditionally are attributed to David himself.) Sheol is definitely not the Christian Heaven.
Later, in 1 Kings 2:6 and 9, in the account of David’s death, we see two more references to Sheol as the destination of the dead.
Your friend may respond that the Church teaches Christ’s sacrifice and resurrection opened the gates of Heaven, and that all the just who had died prior to this event, including those sleeping in Sheol, were then let in. He would be right, the Church does teach that. But this still does not establish whether babies who die without baptism go to Heaven, even if one equates circumcision under the Mosaic law with the sacrament of Baptism, because there is no indication in 2 Samuel that the child had been circumcised. In any event, Mosaic tradition would not have called for that to occur until the eighth day of the child’s life, and the child died on the seventh day.
The teaching of the Church is that neither Sacred Scripture nor Sacred Tradition definitively establishes what happens to the soul of a child who dies before Baptism. I know this is stated in the Catechism, but I would not use that beautiful document in a Scriptural debate with a non-Catholic other than to show what the Church actually teaches. Interestingly, St. Augustine believed unbaptized children could not enter Heaven without that sacrament, despite their presumed innocence of any personal sin. Today, however, we rely on our hope in the boundless mercy and love of God, and we pray for those souls as we do for all the dead.
I hope this helps.
Pax Christi.