He served as the Governor of Fano from 1555 to 1559 and later served as the Governor of Perugia and Umbria from 1559 to 1560. During the reign of Pius IV he settled satisfactorily a long-standing boundary dispute between the inhabitants of Terni and Spoleto. Castagna would later participate in the Council of Trent from 1562 to 1563 and served as the president of several conciliar congregations. He was appointed as the Apostolic Nuncio to Spain in 1565 and served there until 1572, resigning his post from his archdiocese a year later. He also served as the Governor of Bologna from 1576 to 1577. Among other positions, he was the Apostolic Nuncio to Venice from 1573 to 1577 and served also as the Papal Legate to Flanders and Cologne from 1578 to 1580.