Born in Cittiglio, Lombardy, Castelli started his career at Internazionale. He spent 2 seasons on loan at Lombardy side Pro Sesto, then sold to Cagliari in co-ownership deal. In 2001–02 season, he was loaned back to Lombardy for Varese. And in June 2002 bought back by Inter after an auction between the two clubs.
He then left on loan to Serie C1 club Reggiana, where he rejoined ex-Inter team-mate Raffaele Nuzzo. With Nuzzo and Luca Mondini, Castelli worked as the 3rd choice keeper and in January 2003 left for Reggiana's league rival Prato, as understudy of Alessio Sarti. Since the left for Sarti, Castelli became the starting keeper for Prato.
In 2004–05 season he left for Serie C1 side Spezia along with forward Nicola Napolitano, which at that time the club partially owned by Inter. He worked as the backup of Hugo Daniel Rubini who spent previous 5 seasons as first choice except 2003–04 season. In January 2005, he left the club after Spezia signed keeper Alex Cordaz from Inter. At Vittoria, Spezia's league rival, he was the backup of Giancarlo Petrocco.
In July 2005, he left for Lecco, his first Serie C2 club and Lombardy club since leaving Pro Sesto in 2000 and Varese in 2002 respectively. He competed with Maurizio Monguzzi for the first choice position but in January 2006 left for Serie C1 and Lombardy side Pro Patria.
In summer 2006, Castelli remained in Serie C1 and Lombardy, joined Lucchese along with Inter team-mate Mathieu Moreau (which Moreau already spent previous season on loan). He worked as understudy of Alex Brunner and then Massimo Gazzoli.
After the fold of Lucchese in 2008, on 22 September 2008, he joined Modena of Serie B (the first Serie B club since leaving Cagliari), which Castelli had been trailed since 11 September. Originally a backup of Giorgio Frezzolini, he played as first choice since round 26, a 3–0 won Empoli as starter on 16 February 2009, after the injury of Frezzolini. In although Frezzolini recovered, Castelli remained in starting XI. But on 16 May 2009, a 1–4 lost to Bari (later the champion), he was sent off in the 65th minutes and suspended for 1 match. Frezzolini thus returned to starting XI and secured 2 straight win and 1 clean sheet for Modena to win the relegation battle, finished as the 15th, just 1 point higher than Rimini the 18th which Rimini eventually lost in relegation playoff and relegated.
He was then without a club for 7 months, and on 1 February 2010 signed a contract until end of season with Serie B newcomer Crotone. He worked as an understudy of Emanuele Concetti along with young keeper Simone Farelli.
On 19 August 2010 he was signed by Como.
On 29 August 2011 he left for Monza.Spezia
Coppa Italia Serie C: 2004–05