The Real Madrid ace netted in the 118th minute - with Man of the Match Lionel Messi providing the assist - to book La Albiceleste a last-eight date with either Belgium or USA in Brasilia on Saturday.
Switzerland nearly equalised at the death but substitute Blerim Dzemaili had a free header from close range foiled by the post at Arena de Sao Paulo.
The Swiss were the better side in the opening 45 minutes, with Granit Xhaka forcing a sharp stop from goalkeeper Sergio Romero with a low strike just shy of the half-hour mark.
The Europeans could have gone ahead in the 38th minute, but Josip Drmic wasted a one-on-one chance after being released by the impressive Xherdan Shaqiri. Drmic tried to be clever with a cheeky chip and got it horribly wrong allowing Romero to gather with ease.
Argentina struggled for ideas in the first stanza, with Di Maria having one of their few opportunities just before the break when he shot meekly at Diego Benaglio after being teed up by Messi.
The tournament favourites, however, dominated after the interval, as Messi, Marco Rossi - who is suspended for their weekend duel after receiving a second booking at the competition - and Di Maria tested Benaglio with menacing efforts. The Swiss keeper, though, pulled off a string of impressive saves as the game stretched in to extra time.
Alejandro Sabella's men continued to press and got their reward when Di Maria swept the ball home on the angle after being set up by Messi following an error at the back from Switzerland's Stephan Lichtsteiner.
Dzemaili almost forced the contest to penalties but he was agonisingly unable to direct his header on target in the closing stages.