He was Professor of Church History at the Collegio Romano, both before and after the deportation of Pope Pius VII to France (1809–1814) and the French occupation of Rome.
During the occupation, he was observed to be friendly to the French authorities and an admirer of Napoleon, and on the return of the Pope to Rome and the beginning of papal actions against collaborators, Ostini was denounced.
Pius was determined to deport him to Corsica, but Bishop Giuseppe Menocchio, the Pope's confessor, who had remained in Rome during the occupation, intervened and pointed out the good work that Ostini had done in converting a number of prominent Protestants to the Catholic faith.
[5] He served in Lucerne as Nuncio to the Swiss Confederation in 1828, where he signed the Conventions that incorporated the Thurgau and the Aargau into the newly organized diocese of Berne.
Ostini was named a cardinal in the consistory of 30 September 1831 by Pope Gregory XVI, but the appointment was kept secret until the day that he was transferred to the diocese of Jesi on 11 July 1836.