I think they can turn at any time, but it's generally assumed that they turn round before 36 weeks. I think this is because from 36 weeks onwards they are a bit too squashed to turn on their own (but they can still turn at 40 weeks if they really want to and some do).
My baby was breech up until 36 weeks and then got herself into position. I'm hoping she stays there! The midwife started checking and noting her position at about 31 weeks.
If baby is still breech at 36 weeks they start looking at ways to get them to turn, such as acupuncture, and certain manual moves that drs do, etc.
A friend of mine had a breech baby until 40 weeks when she had a caesarean. The baby turned on the morning of the caesarean but the drs went ahead with it anyway.