Big-serving second seed Raonic was coming off his third straight San Jose Open title but was unable to recapture that form in his first round match against his 20-year-old opponent.
Wildcard Sock, ranked 168th in the world, was able to match Raonic's serve and finished with 11 aces to the Canadian's 12 in a match that featured just three service breaks.
The final set was tied at 5-5 but Sock grabbed a late break before finishing off the duel in two hours and 10 minutes.
In other action, former world number one Lleyton Hewitt showed his grit by fending off a pair of match points in the second set before overcoming Taiwan's Lu Yen-Hsun 2-6 7-6 6-4.
After dropping the opening set, Hewitt went up 4-1 in the second before momentum completely swung against him.
The Australian has never been one to shirk a challenge, however, and showed he still has mettle to spare, even if he was aided by seven Lu double-faults.
Germany's Tommy Haas, who lost to Raonic in the San Jose final last week, was also a winner, 7-6 6-4 over Russia's Evgeny Donskoy.
Women's second seed Sofia Arvidsson also crashed out, losing 6-1 3-6 6-3 to New Zealand's Marina Erakovic, while top seed Kirsten Flipkens outlasted Lesia Tsurenko 7-5 3-6 6-3 in her second round tie.
- Sports & Recreation
- Lleyton Hewitt