Every ~2,000 miles. I had a cable break in the body of a Shimano STI lever at around 2,500 miles (I think the 105 5800 shifters were notorious for this), and after having to drill holes in the shifter to extract it, that was when I decided 2,000 miles was a nice round figure to replace cables and do a checklist of other maintenance items. Re-grease all contact points, check all bolt tensions, check the hubs, spoke tension, wheel true, hanger alignment, inspect / adjust / bleed brakes. Having a shift cable break mid-ride is not the end of the world since you can easily fix the cable to a middle'ish cog and have a single / dual speed bike for a bit, but again, it's a big problem if it breaks inside an STI lever body.