within the youth setup of the Piedmont-based club, Castiglia transferred to city rivals, Juventus Football Club in 2005. Torino bankrupted in 2005 despite winning the promotion back to Serie A; their players were allowed to leave the club for free, although some players were remained for the newly formed entity "Torino FC SpA" for 2005–06 Serie B.
After joining Juventus, Castiglia registered with the club's youth sector at the start of the 2005–06 season, having spent some of his formative years in the under-17 team in 2005–06 season, under-18 team in 2006–07 season and the under-20 team for the last 2 seasons of his youth career. He also played once in the Campionato Nazionale Primavera for their under-20 team in 2006–07 season. Castiglia began to earn first-team call-ups during the 2007–08 Serie A campaign, by then coach, Claudio Ranieri. His senior debut came on 27 January 2008, when he came on as a substitute in a 1–3 away victory over Livorno in Serie A league match. He made one other senior appearance in Serie A for the club, coming on as an 89th minute substitute in a 3–3 draw at Sampdoria on the final matchday of the 2007–08 Serie A season. He also made his debut in the UEFA Champions League during the 2008–09 edition, coming on a substitute in a 0–0 draw with BATE Borisov. In February 2009, he helped guide the Juventus Primavera team to win the Viareggio Cup. In July 2009, Castiglia was sent out on loan to Serie B club, A.C. Cesena, but he was limited to just two first team appearances. Re-called by Juventus in January 2010, he was immediately loaned to Lega Pro Prima Divisione club Reggiana, making 8 league appearances. He made a return to Juventus once more on 30 June 2010, following the expiration of the loan deal, though he was again sent out on loan to the Lega Pro Prima Divisione with F.C. Esperia Viareggio thereafter. With Viareggio, Castiglia made 30 league appearances and 4 appearances in the 2010–11 Coppa Italia Lega Pro, and on 30 June 2011, he returned to Juventus. Castiglia represented the reserve team during the 2011 pre-season as overage player, along with fellow first team players Albin Ekdal and Oussama Essabr.
Co-ownership with SPAL & Vicenza
On 29 August 2011, he was sold to SPAL 1907 in the Lega Pro Prima Divisione in a co-ownership deal. He made his debut for the club on 11 September 2011 in a 1–0 away loss to Taranto. He went on to score 2 goals in 22 league matches for the club during the 2011–12 Lega Pro Prima Divisione season. On 20 June 2012, however, he returned to Juventus after the co-ownership deal was not renewed. On 3 August 2012, Juventus sold Castiiglia to Serie B side, Vicenza Calcio on another co-ownership deal for a nominal fee of €500. Castiglia was a regular performer for the club during the 2012–13 Serie B, making 33 league appearances and scoring 5 goals, though his efforts were not enough to save the club from being relegated to the Lega Pro Prima Divisione for the 2013–14 Lega Pro Prima Divisione.
Juventus return
Despite the co-ownership deal being renewed in June 2013, Juventus bought back Castiglia on 21 August 2013 for €350,000 in order to finalize another transfer for Castiiglia. On 2 September 2013 he joined Serie B outfit Empoli on a season-long loan agreement. With 19 appearances in the league, Castiglia helped the club gain promotion back to Serie A for the first time since 2008 after their 2nd-place finish in the 2013–14 Serie B campaign. He returned to Juventus on 30 June 2014.
In summer 2014 Castiglia was signed by Pro Vercelli in a temporary deal. In 2014–15 winter transfer window, Castiglia and Giuseppe Ruggiero joined Pro Vercelli outright, for €1.5 million and €250,000 respectively, with Cristian Bunino moved to Turin, for €1.75 million.