As soon as you come home from the hospital!
Seriously, it is never too early to get your little one in a bedtime routine. It took us about 6 weeks to get our footing as parents, but we immediately swaddled our little one and put him in his own place to sleep. We moved him from the pack and play in our room to his crib at 7 weeks because he was sleeping well enough that I was concerned we would wake him because of my husband's "loud" sleeping.
We've always had a routine. That routine has changed significantly as he's gotten older, but it always has revolved around bedtime, clean pj's, rocking, and a story. Until he was weaned from the bottle at 13 months, he got a bottle every night before bed. Then he graduated to a sippy cup with milk and a Nutri-grain bar and now he doesn't want anything. We also added in brushing his teeth about 3 months ago and allowing him to choose his story (from 3 options).
He has slept through the night since 7 weeks, exculding sickness and teething. We have done CIO, but it's never more than one or two nights before he gets back in the routine.