You'd have to be an adult.
Until then,should you need to state a preference, you'd be able to state a preference in a court hearing in your mid teens.
But your preference testimony is only one factor a judge would consider on the question.
The right of as minor to testify is handled on a case-by-case basis. A motion would have to be filed asking that you be allowed to testify, and the judge would probably want to meet with you to see if you have the maturity to handle making such a big decision. Even if you are allowed to testify and state a preference, that is only one factor that the court would examine to determine what your best interests are and how best to serve them.
Sign up to receive a 5-part series of useful information and advice about child custody law.