NO, the death of the child was not re-payment for the sin of David. It was the normal "Wages" for the Sin. It is already "preprogramed". The Bible plainly says that "the Wages of Sin is Death". God does not play the "Tit for Tat" game. But he does allow the Lucifer to extract his wages when we transgress. It is only God's will that restraines Lucifer. As we grow more distant from God's will, by exercising our freewill to sin, the more Lucifer is unleased.
God's hand is stead. It is we who stray. God is a God of Love that is true. But he is also a God of Justice and of Judgements. It is not God who will condeam us, It is our own freewill to sin that condeams us.
Just my theological perspect.