How did David punish his ten concubines for being publicly raped by his son?

By refusing to have sex with them and forcing them to "keep house" for him for the rest of their lives

The public rape David's concubines was God's punsihment to David for his affair with Bathsheba. (See 2 Samuel 12:11)
And David came to his house at Jerusalem; and the king took the ten women his concubines, whom he had left to keep the house, and put them in ward, and fed them, but went not in unto them. So they were shut up unto the day of their death, living in widowhood. 2 Samuel 20:3