John T. Casteen III, Virginia's secretary of education, was named president of the University of Connecticut yesterday to succeed John DiBiaggio as head of the state's largest university.

Casteen, 41, a medieval scholar and former dean of admissions at the University of Virginia, was the top choice of a committee formed last November when DiBiaggio announced that he would become president of Michigan State University.

Casteen will become the university's 11th president Aug. 1 at an annual salary of $95,000. He and his wife, Lotta, were present for the announcement in Hartford, where Casteen met with Gov. William A. O'Neill and members of the board of trustees.

Casteen said his mandate includes moving the university into the ranks of the country's top 20 research institutions, an area in which he said the school has ranked near the bottom 50.

As education secretary and a member of Gov. Charles S. Robb's cabinet for three years, Casteen oversaw Virginia's elementary, secondary and higher education systems as well as museums, libraries and cultural programs. A Virginia native, Casteen was dean of admissions at U-Va. from 1975 to 1982 and an assistant professor and associate professor of English during that period.