Sami Hyypia's side went into the match on a fine run of form and were quick to stamp their authority on the tie, with Son Heung-Min and Sidney Sam threatening in the early stages.
Sociedad were restricted to set piece opportunities for much of the first period but did register a strike on target through Antoine Griezmann, who had a free kick tipped round the post by Bernd Leno.
Just moments before the interval Leverkusen's pressure finally told as Simon Rolfes broke the deadlock, reacting quickest to tap home from close range after Claudio Bravo's save from point-blank range.
Sociedad were lively straight after the break and were soon given a wonderful chance to level with the award of a penalty kick.
Carlos Vela stepped up to take but saw his spot kick saved by Leno, but followed in to atone for his error and stroke home the equaliser.
Vela then spruned a glorious opportunity to give the Spaniards a shock lead, taking too long to shoot as his eventual effort was blocked behind by Leno.
The visitors were made to pay a heavy price for that miss, with Leverkusen snatching a last-gasp winner as late pressure finally told.
Hegeler was the man who curled home the decisive strike, leaving Bravo with no chance as his free kick swirled into the top corner.