Children don't ever get to "decide" who they live with and spend time with; that's for the parents to decide, or for the court to decide if the parents can't agree. (That's why, legally, minors are minors, and adults are adults.)
The court will CONSIDER the wishes of a minor child in making a custody decision, if the minor child is of an appropriate age and maturity.
Judges will usually be MORE interested in the REASONS for the child's preference, than in the preference by itself, and will also be interested in how the rest of the child's judgment and decision-making looks (that's the "maturity" part).
If the rest of the child's judgment looks good and mature, he or she will get more of an ear; if, for lack of a better description, if a child is messing up in the rest of his or her life (poor school performance, law enforcement or discipline problems, etc.) he'll get less of an ear.
I've seen a judge tell a sixteen-year-old: "I understand you want me to change custody; you're messing up in school, you're in trouble with the law; so your judgment and decision-making, right now, looks lousy. No custody change right now. If you manage to get your act together, and you come back in a year, I'll take another look."
Judges also are often VERY unhappy with a parent who discusses the custody issues of a case with children who are NOT yet of appropriate age or maturity.
There is no magic age when children get to decide where to live. The best interest of the child is the standard.
The law regarding a child's 'right'* to choose is a matter for each State and jurisdiction. The judge in most States, not the child, makes the decision based on the best interest of the child. Although not a standard by any means, many States have begun to give 'consideration' to a child's declaration of custodial preference when the child reaches the age of twelve or thirteen, sometimes fourteen. There are even cases when children of age 9 are allowed to testify.
The judge is normally given almost unlimited latitude in whether or not she or he listens to a child and how much weight to give to the child's wishes. In short, there is no specific "age" but the younger the child the less likely for a judge to give the stated preference much weight.
Good luck to you.
NOTE: This answer is made available by the out-of-state lawyer for educational purposes only. By using or participating in this site you understand that there is no attorney client privilege between you and the attorney responding. This site should not be used as a substitute for competent legal advice from a licensed CA professional attorney that practices in the subject practice discipline and with whom you have an atttorney client relationship along with all the privileges that relationship provides. The law changes frequently and varies from jurisdiction to jurisdiction. The information and materials provided are general in nature, and may not apply to a specific factual or legal circumstance described in the question.
Sign up to receive a 3-part series of useful information and advice about child custody law.