Jhon Cordoba opened the scoring for the hosts before Sargis Adamyan and Locadia's second half efforts lifted Alfred Schreuder two points below leaders Borussia Moenchengladbach.
Schreuder made one change from last weekend's victory over Paderborn with Stefan Posch taking Kevin Akpoguma's place in defence.
Achim Beierlorzer's outfit remain in 17th spot with only two wins all season despite handing attacker Cordoba just his second league start of the season.
Colombian Cordoba repaid the faith shown in him by the Billy Goats' coach Beierlorzer to claim his second goal in three appearances.
Attacking midfielder Louis Schaub laid-off to Cordoba at the edge of the box and the 26-year-old struck home.
In-form Hoffenheim responded three minutes into the second-half.
Defensive midfielder Sebastian Rudy chipped the ball to the path of Adamyan inside the penalty area and the Armenia winger side-footed on the volley to equalise.
Hoffenheim's winner came after seven minutes of additional time as Dutch youth international Locadia scored his third goal of the season with a penalty after referee Robert Kampa had checked the decision with VAR.
Saturday's action sees managerless Bayern Munich host Borussia Dortmund in the champions first league game since Niko Kovac was sacked last weekend's 5-1 drubbing at Eintracht Frankfurt.
League leaders Moenchegladbach welcome Werder Bremen on Sunday with French forward Marcus Thuram looking to score for a fifth straight match after netting an injury-tme winner in the Europa League against Roma midweek.