"If you're outraged by those words, then you're in the right place," Lieutenant General Jay Silveria said in an address to cadets, faculty and staff at the academy in Colorado Springs, footage of which has since gone viral.
"You should be outraged not only as an airman, but as a human being," the academy's superintendent said.
Five African-American students at the Academy's Preparatory School found racist comments on dormitory message boards earlier this week.
One posted an image on Facebook showing a whiteboard with "Go home, nigger" written on it, and parents then alerted faculty.
"That kind of behavior has no place at the Prep School, has no place at USAFA (US Air Force Academy) and it has no place in the United States Air Force," Silveria said.
"If you can't treat someone from another race or different color skin with dignity and respect, then you need to get out," he said.
Related reading
Racism, hate and a new online tool to help young people
At the close of his remarks, the general invited those gathered to take out their phones and record his message.
If "you need my words, then you keep these words, and you use them and you remember them and you share them and you talk about them: If you can't treat someone with dignity and respect, then get out."
US Senator John McCain, a former naval officer who was held captive in Vietnam, tweeted a video of Silveria's remarks, saying that it was an "important statement."
Backdrop of racial tension
"I agree, there's no place for racism or bigotry in our military or this great nation," McCain said.
The graffiti -- and Silveria's reply -- come at a time of heightened focus on racism in the United States, a context he noted in his speech.
"We would... be tone-deaf not to think about the backdrop of what's going on in our country, things like Charlottesville and Ferguson, the protests in the NFL," he said.
In mid-August, top military officers offered strong condemnation of racism after a violent neo-Nazi and white supremacist rally over the removal of a Confederate statue in Charlottesville, Virginia.
One woman was killed when an avowed white supremacist plowed his car into a crowd of people after the Charlottesville rally turned violent, and numerous demonstrators were injured during the events of August 11 and 12.
The response of senior officers was in contrast to that of President Donald Trump, who suggested there was blame "on both sides," and that there were "very fine people" among the white supremacist protesters -- remarks that were widely criticized.
There have been heightened calls for the removal of other Confederate statues in the wake of the violence.
Ferguson is a suburb of St Louis that became the focus of national attention following the 2014 police killing of Michael Brown, which sparked demonstrations and a heavy-handed police response.
Protesters have recently taken to the streets in St Louis amid outrage over the acquittal of a white former police officer in the shooting death of a black man.
And NFL players are protesting against racism by kneeling during the national anthem before games -- protests that have drawn repeated criticism from Trump.