The Old Lady have made a habit of winning under Allegri during his five years in charge, lifting five successive league titles, though they fell short of those standards in Genoa and dropped points for a fifth Serie A game on the bounce.
There was a distinct end-of-season feel to the majority of the first half, with excitement lacking and clear-cut chances at a premium.
Proceedings picked up at the start of the second period, with Juve going close three times and having a Moise Kean goal disallowed, but Sampdoria's more clinical finishing saw them claim victory.
Defrel opened the scoring six minutes from time and Caprari's gorgeous free-kick allowed Samp to finish the season in style.
It took 34 minutes for the game to show signs of life, as Gaston Ramirez's cross picked out Serie A top-scorer Fabio Quagliarella and his acrobatic volley from a tight angle found the side-netting.
Juve responded and went even closer a few moments later, but Paulo Dybala could not bundle in from close range, with Jacopo Sala making a vital last-ditch intervention.
The visitors played with greater intent at the start of the second half, with Kean shooting just wide from 12 yards and Dybala striking a volley agonisingly over shortly after the restart.
Kean thought he had broken the deadlock with 10 minutes to go when finding the net after latching on to a throughball, but it was disallowed for offside.
And Sampdoria capitalised soon after, as Defrel found the bottom-left corner with a scuffed effort after linking with Manolo Gabbiadini.
Caprari wrapped things up at the end, firing his unstoppable free-kick into the top-right corner from 25 yards, bringing the curtain down on Allegri's decorated Juve spell.
An underwhelming end to Allegri's tenure
Although the match mattered little, with Juve long having wrapped up the Serie A title, there will surely be a little disappointment from Allegri's perspective, as his tenure ends with a 2-0 defeat amid a poor run of one win in nine across all competitions.
Nevertheless, he will likely be content with being able to give some of the club's youngsters an outing.
Pereira enjoys a promising first start
Brazilian midfielder Matheus Pereira has not quite managed to live up to the early expectations of him yet, but he made his first start for Juve's senior side on Sunday and certainly did not look out of place. He produced some inventive passes and showed an eye for a cross, generally appearing entirely at ease with top-flight football.
Dybala fails to take the lead
With Cristiano Ronaldo not involved, the opportunity was there for Dybala to be Juve's star man in attack, but he struggled to make much of an impact and lost possession more times than all of his team-mates, bar Juan Cuadrado.