If this question were to come to me in a face-to-face conversation, then my immediate response would be to sit with you in the sorrow at the grief you must be experiencing. It would be a time for me to listen and provide comfort, before I spoke. I hope you have a good network of friends and family around you at this time. Be assured of my prayers for you and your family.
In essence you have asked,“if my baby dies before (or shortly after) his birth, will he go to heaven?” In answer to this, I want to point you to the character and promises of God that will give you great HOPE and PEACE for his future - the same hope and peace we all have who have put our faith in him.
Firstly HOPE. God is a god abounding in grace and mercy and WANTS people to be saved. We are his creation and he loves us deeply and despite our rejection of him, he still shows us his grace and mercy. The greatest display of his grace is that he provides us with a fresh start, even though we deserve the complete opposite. This fresh start is possible because while we were still sinners, Jesus died for us (Romans 5:8). We receive this fresh start by repenting of our sin, and by following Jesus as our Lord and Saviour. In the case of an adult, we can easily see how this response is achievable AND necessary.
But, what if a person is not physically (or cognitively) able to repent and believe ... such as an unborn baby? At this point I must say that a ritual will not help at all. A ritual is powerless to change our eternal state, it is only a symbol. It may ease our pain and sorrow (and in this sense is a good and helpful) but only Jesus can sufficiently deal with our sin.
At this point your son’s life is in the hands of his Creator and because of this we can have PEACE. We know that, like all people, children belong to God because he has created them and loves them. And God has shown us again and again that he will do what is right (Gen 18:25). He is a loving God, a good God, a God who is always fair. And we know that Jesus’ death is sufficient for your son. And so we leave our unborn babies in the hands of a gracious and loving God who will do right. And while it may hurt, there is peace to be found in letting them go, and trusting them to the goodness of God.
If you want to read more then look at http://www.sydneyanglicans.net/mindful/children_and_salvation/