Pekhart gave Nuremberg the lead after nine minutes before Andreas Beck equalised in the 22nd minute. The visitors went ahead again in the 45th minute through Daniel Didavi and Pekhart made it 3-1 after 71 minutes.
Edson Braafheid pulled a goal back late on but it was not enough to deny Nuremberg, who moved onto 42 points with their first victory over Hoffenheim and they are now three points adrift of seventh place.
Hoffenheim came into the contest with a slight chance of qualifying for the Europa League themselves but today's defeat brought an end to that.
Nuremberg went ahead when Javier Pinola stole the ball from Beck, leading to a long-distance shot by Didavi which Hoffenheim keeper Tom Starke could only block in the path of Pekhart, who pounced on the loose ball to net.
Hoffenheim equalised 13 minutes later with Knowledge Musona's pass being blocked by Nuremberg keeper Raphael Schafer back to Beck, who poked home a shot for his first goal of the season.
Nuremberg reclaimed the lead on the stroke of half-time as Markus Feulner crossed from the right side into the middle where Didavi beat Starke. At that point, Didavi had scored or assisted on 11 of Nuemnberg's last 13 goals.
Pekhart struck again in the 71st minute as Starke stopped Pinola's shot and then saw Pekhart's rebound attempt go off him and against the crossbar but Pekhart got up quickly to head in the second rebound.
Braafheid made things interesting at the end, firing home Peniel Mlapa's cross in the 88th minute, one minute after coming into the game, but Hoffenheim could not force a late equaliser.=