Lannan threw 7 1/3 innings, giving up three earned runs and picking up his fifth win of the season.
Dunn's 19th homer of the year came after Ryan Zimmerman ripped a double down the right-field line and put the Nationals ahead, 2-1.
"I got ahead in the count, and I was trying to elevate a fastball and I just put it right down the middle," Hernandez said. "I put it on the tee for him. That's what he does with mistakes -- he hits them out. The ball went pretty far."
Four hundred and forty-two feet, to be exact.
That pitch to Dunn was just one mistake in a game of several for the Orioles, however. Baltimore committed some blunders on the bases, both offensively and defensively.
The Orioles took the early lead in the second inning, as Nolan Reimold, who led off the inning with a walk, came in to score on an Oscar Salazar single to left field. That put Salazar at first and designated hitter Luke Scott at third base with no outs.
Matt Wieters lined the next pitch to Washington first baseman Nick Johnson, who then caught Scott dazing at third to pick up the double play. Robert Andino then grounded out to the mound to end the threat, leaving the Orioles' lead at one.
The one run wasn't quite enough support for Hernandez to earn his second career Major League win, despite some early signs of success from the right-hander. Hernandez allowed just two hits through the first three innings before running into Dunn's bat in the fourth.
The Nationals added insurance runs in the top of innings six through eight. One run came in when Josh Willingham scored on a throwing error to third base by Wieters. Wieters has committed an error in three of his past four games, and this most recent one put the Nationals ahead, 5-1. Earlier in the game, Wieters dropped a throw from center fielder Adam Jones on a play at home, allowing the Nationals to increase their lead to 3-1.
"I'll tell you what, I just missed it," Wieters said. "It was one of those things where I knew the guy was dead, and Jones made a great throw. It hit the glove and popped out. I just missed it."
The mistakes weren't done for the Orioles, however. In the bottom of the eighth, Aubrey Huff knocked a single into right-center field, allowing Andino to score from second base. Instead of staying at first, Huff tried to hustle out a double, but he was tagged out at the base to end the inning.
"That's not a good decision," Orioles manager Dave Trembley said after the game, visibly frustrated. "You've got the tying run coming up behind you. That's not a good decision."
Although he was less than pleased with some of the mistakes made on the field on Sunday, Trembley did say Hernandez was the reason the team was in the game. Hernandez was able to keep his go-to pitch, his fastball, in good locations and pitch his longest outing of his young career. Trembley also noted that two throws to second made by Wieters showed promise, even if the one to third slipped away.
"I'll take those two throws to second base," Trembley said. "Those were right on the button. You know when the guy was stealing third, it looked like he had third stolen. If he had to do it over again, he probably would have just flipped the ball back to the pitcher. He rushed, opened up and let the ball sail on him."