Los Angeles, which has won 16 of its 20 home games, fell below .500 on the road with its second straight setback.
San Diego starter Clayton Richard (2-5) gave up two runs in the first and then allowed only two more hits through a seven-inning performance. He struck out six, did not walk a batter and won for the first time since April 8, when he also defeated the Dodgers.
Headley's homer came in the first, cutting San Diego's early two-run deficit in half. Cameron Maybin and Chris Denorfia both reached on sixth-inning singles and Headley drove them home with his double to left.
A bases-loaded walk drawn by Maybin in the seventh accounted for the fourth San Diego run.
Andrew Cashner struck out the side for the Padres in the eighth and Dale Thayer worked around a one-out walk in the ninth to earn his fourth save.
Chris Capuano suffered his first loss of the season while working 6 1/3 innings. Capuano (5-1) gave up all four runs on six hits with three walks and six strikeouts.
Elian Herrera and Andre Ethier each drove in a run for LA in the first inning.