Gaffney carried the ball 20 times and Ty Montgomery provided a rushing and receiving touchdown for the Cardinal (11-2, 8-2 Pac-12), who will make their 14th appearance in the Rose Bowl with a second straight conference championship.
There they will face Michigan State, which knocked off previously unbeaten Ohio State Saturday for the Big 10 championship.
Kevin Hogan completed 12-of-18 passes for 277 yards with a score as Stanford ended its Pac-12 season with three straight wins.
The Sun Devils (10-3, 8-2) came up short in their bid for a first conference championship since 2007.
Taylor Kelly led ASU with 173 passing yards on 17-of-25 efficiency.