As per the shastra one attains dwijahood i.e twice born when the samskara i.e sacred thread ceremony is performed. In absence of this even the brahmin is not entitled for vedas.
For performing this samskara there are various ages recommended for various varnas.
Just like brAhman the kShatriya & vaishya are also entitled to upanayana samskAra and gAyatri as is evident from different gRhyasUtra-s for eg, Apastamba says :
“ गर्भाष्टमेषु ब्राह्मणं, गर्भैकादशेषु राजन्यं, गर्भाद्वादशेषु वैश्यम्।। (आपस्तम्बः)” in the eighth year from conception i.e. the 7th year from birth, the brAhman should be intitiated into gAyatri. Similarly, in the 10th year from birth for kShatriya and 11th year for vaishya
brAhmaNaH kShatriyo vaishyaH trayo varNAH dvijAdayaH
saMskRtAshcAnyathA shUdrAH evaM vedavido viduH
tasmAdayaM suto me.adyaH shUdravat vartate shishuH
upanItaH kriyArhaH syAt iti vedeShu nirNayaH
rAjJAmekAdashe varShe sadopanayanaM smRtaM
aShTame brAhmaNAnAM ca vaishyAnAM dvAdashe kila (devI bhAgavata 7-7)
“The three varNa-s of brAhmaNa, kShatriya and vaishya are dvija (twice born) only if they undergo the upanayana saMskAra otherwise they are indeed considered to be shUdra in the absence of saMskAra”
However for changing or migrating the varna there is no specific age mentioned it can be anytime.
For example in Satyakama jabali he attained higher level by performing tapas in quite an early age. In comparison, it took more time for sage vishvamitra to attain rishihood.
Also acharya drona and his son ashwatthama migrated to kshatriya varna through their deeds and profession.
So there is no fixed age. For example one may act like a brahmana till certain age then he may switch to certain trade related profession of vysya and so on.
It depends on the balance and predominance of certain gunas in him.