There isn't a specific age. The judge determines the welfare of the child through various investigative reports, then speaks with the child. If the child can show proper maturity, independence and a knowledge of what they feel they need with the ability to articulate said need, the judge may then determine that the child is sound enough to make that choice. Every case is different. Let me add that I have never seen a child younger than 10, given the right to choose, and I've experienced many cases to determine residential custody.
Growing up in a divorced household and dealt with this issue my whole life...state of Texas...the child has the right to choose without the parents say so at the age of 12 who they want to live with. Neither parent can influence what the child wants nor can they go to court for custody. But if I am not mistaken I think within the last year or so it has changed to the age of 10. But each state is independent with their own laws on this issue. I hope this helps.