It's going to vary from person to person, but it's certainly possible to go 12+ months between purchases without banks batting an eye.
It took years for Barclays to close one of my cards for inactivity. Once they noticed, they notified me that I had 30 days to use the card, then offered a lower APR after ~60 days, then finally closed it out after ~90 days. I just came up on the 12 month mark of inactivity with Citi and it's still open. If/when they do close it, I'll make a note as a data point.
If you're worried about it or afraid they won't notify you before closing the card, then err on the side of frequent and do something every 3-6 months.
The best option would be 3 months if you're not using them but still want to keep them active.
Also, be clear (to yourself) why/if you really need to keep them. A lot of people have got a bunch of cards early on (in their credit or rebuild) that really have no useful function now. If you have to struggle to remember to keep them active, evaluate whether their closure would be that impactful!