Actually, it's very complicated. It's not only for the age, but also for the social status/position, the relationship between us, depending on the person and family, etc. I'll write about "my cases".
I would use さん(san) for:
my bosses, the people whom I don't know, whom I meet for the first time, who aren't my close people
the customers (san/sama), co-workers, some of my husband's relatives, my parents friends
my friends who are older than me (however, I use "chan" for close friends of mine)
the people who are older than me if I know their age/generation
I use ちゃん(chan) for:
small/young girls, female friends of my children, some of my female friends, some of my female relatives
*except the male who has nickname with "chan"
my children call almost all of my female friends with "chan"
*it depends on the person/family
some of my nieces/nephews call me with "chan" and some use "san"
*it depends on their family
I use くん(kun) for:
small/young boys, male friends of my children, some of my male friends, some of my male relatives
my children call some of their male relatives with "kun" and others with "san"
After all, there are any specific rules. All are depends on the relationship between people. If you want to ask me more, please feel free to ask me. I hope this was helpful.