"Now that they've put the grease back on," he said, "no one will ever match your time."
Obama mentioned the controversy over the Internal Revenue Service targeting conservative groups only obliquely, noting that the vast majority of "civil servants do their jobs with professionalism" and that "we've seen how the actions of a few can undermine the integrity of those institutions."
But he said that the military remains the most trusted institution in America.
"I cannot promise you a life of comfort and ease, for you have chosen an ancient path, the profession of arms, which carries all the perils of our modern world," he said.
"But I do know this: As you say farewell to Bancroft Hall, as you make your way down Stribling Walk one last time, you're becoming the newest link in a storied chain."
Baltimore Sun researcher Paul McCardell contributed to this article.
Class of 2013
Total graduates: 1,047
Navy Ensigns: 764
Marine Corps 2nd Lieutenants: 264
Air Force 2nd Lieutenants: 3
Foreign officers: 16
Hispanics: 36 percent
Blacks: 17 percent
Asians: 11 percent
Multiple races, ethnicities: 14 percent
Source: Naval Academy