Ashwin, who opened the bowling for the second time in the match, bowled 15 overs continuously as the opposition crumbled in 29.1 overs at the Oval.
Quite a few of the wickets came by way of batsmen's profligacy.
Opener Steve Davies edged one behind as he went for a drive against a delivery that started outside the off-stump and turned further away.
No.3 batsman Tom Lammonby fell to a reverse sweep, as he ballooned one off a top edge for Rikki Clarke to take the catch.
Captain James Hildrith played back and was out leg-before.
George Bartlett also played on the backfoot and was bowled to fall as Somerset's sixth and Ashwin's fourth wicket.
Ashwin, one of only three Indian spinners to take 400-plus Test wickets, then removed Roelof van der Merwe, caught at forward short-leg off an inside edge to complete his five-wicket haul.
The offie then removed No. 8 Ben Green with a flighted delivery that spun in and went past the batsman and hit the stumps.
Ashwin had failed miserably in the first innings as his 43 overs yielded just one wicket for 99 runs.
The 34-year-old then failed with the bat in Surrey's first innings as he managed only a first-ball duck to left-arm spinner Jack Leach.
Ashwin is playing a one-off county game as a warm-up for the Test series beginning on August 4. He will now join the Indian team camp that begins in Durham on July 15.