European champions Italy, who missed out on a place at the World Cup in Qatar, finished top on 11 points from six games, one point above second-placed Hungary who needed to avoid defeat to secure a place in their first Nations League semi-finals.
Raspadori took advantage of a mistake by the defence in the 27th minute to convert a rebound from the edge of the box.
Hungary then had a great chance to equalise just after the break but goalkeeper Gianluigi Donnarumma kept out a flurry of shots by Loic Nego, Callum Styles and captain Adam Szalai, who on ended his international career after the match.
Midfielder Dimarco made it 2-0 for the visitors in the 52nd minute when he blasted the ball into the roof of the net from close range.
"We were excellent for 70 minutes. The last 20 I didn't like too much," Italy coach Roberto Mancini said.
"It's important to have reached the Nations League final four for the second time, but the previous results unfortunately remain.
"Let's say that we were good at restarting and setting up a group that has values on which you can work.
"The goal? It's bypassing the month of December," he added, with his team sidelined for the World Cup which runs from Nov. 20-Dec. 18.