I don't know if there is an optimum age. My friend stopped her son using his around 4 months or so because every time he dropped it out his mouth in his sleep he would wake and cry. I had the same with my daughter but rode through it. She is now 2.5 years and we've gotten rid of it in the day in preparation for getting rid of it at night for good later this year. She's actually been really good about not having it in the day so hopefully will be the same for when we get rid completely.
I just asked my toddler’s dentist this the other day because I had my newborn with me. He said by age 3 is really when they would like to have them stop using it. It’s actually protective against SIDS in the early months. For now I’m going with the pacifier because my son never took one and it’s somewhat freeing to have something else that soothes my daughter other than nursing!
Just wanted to add that some babies ween themselves off their dummies. My niece started refusing her dummy around 7-8 months.
Mine is 7 months and has started rejecting it. That being said we were never reliant on it...only used to go down for naps but she'd spit it out as she fell asleep.
Between 6-12 months is the recommendation due to teeth; before this you may also struggle to find alternative methods to sooth. No harm is using the dummy at all at this point x