Diouf scored the game's only goal in the eighth minute to give some respite to Hannover, who had lost three of their last four matches but now improve to 29 points.
Hoffenheim remain in the heart of a relegation fight with 16 points, after just one win in their last 11 matches.
Hannover made the decisive breakthrough on a counter-attack as Szabolcs Huszti crossed from the left into the middle, where Diouf headed home.
The hosts were close to doubling the advantage after 32 minutes but Sofian Chahed's long-range shot went just wide.
Hoffenheim found their way into the match and nearly equalised four minutes later with Eugen Polanski sending a through ball to Tobias Weis, who could not beat Hannover goalkeeper Ron-Robert Zieler.
Weis was again stopped by Zieler in the 40th minute, this time with a shot from the edge of the area.
Hannover tried to counter-attack in the 58th minute but Huszti shot just wide.
The hosts missed a golden chance to make it 2-0 nine minutes later as Diouf homed in on Heurelho Gomes' goal - but the Senegalese striker could not convert.
Hoffenheim had one more chance with 10 minutes left but Joselu could not control Kevin Volland's cross as he hoped.
The hosts finished on the front foot and Hoffenheim defender David Abraham needed to clear away a Jan Schlaudraff cross in front of Diouf in the 86th minute.