Have Military Law Questions? Ask a Military Lawyer.
There are regulations that require that a long term soldiers be considered for retention or medical retirement rather than separation, and that any separation be reviewed for fairness at higher levels. They don't actually take age into consideration, but rather, length of service because the issue is potential loss of retirement.
It is not ageism to not have a statute that creates that age protection though. Ageism would be to not treat those over 40 in the same way as everyone else. To have a statute preventing separation, that would be treating people ver 40 differently than everyone else and nothing in the law requires those of age to get special treatment.