When was the first time in history (that we have a record for) that sex and/or violence became inappropriate for children to see and/or know about (more than it was inappropriate in front of adults)? Do we know what caused this?
When punishing the immoral, looting doesn't pacify. Using physical violence against the elderly does not set good examples for the children. Ignoring the law out of love for your children does not protect the country.
The context is that, during the Chu's conquest of Deng, two royal princes beat up and robbed an old man when he refused to hand his basket over. To the shock of his courtiers, King Wen ordered them executed. The passage above is the king's explanation for his order. Note that "punishing the immoral" refers to the war against Deng, as that was a common casus belli at the time.
Not a perfect example since it's only a specific kind of violence, and doesn't explicitly mention doing it in front of the children. That said, if beating an old man was bad enough merit executions for the sake of the children even if they weren't watching, one presumes the king wouldn't approve of doing it in front of the children either.
As for violence being inappropriate for children to see, that view is not universal even now.
Even today there are examples of people using violence, including killing, torture, rape, etc., against groups of people including children. Unless all the children are killed first some of them will view some of the killing, torture, and rape inflicted on other members of the group. Thus most genocides and massacres in history involve children seeing acts of violence.
Up until about 150 years or so ago, most executions in western culture were public, and people, including children, came to executions for entertainment and instruction, watching men, and women, and sometimes children, being executed, sometimes by torture.