Obama's advice to a group of high school students followed reports that prospective employers may be mining social networking sights for background information on job applicants.
He offered his nugget of advice to a student at an Arlington, Virginia school who asked him in a roundtable how he could get to be president.
"First of all, I want everybody here to be careful about what you post on Facebook, because in the YouTube age whatever you do, it will be pulled up again later somewhere in your life," Obama said.
"And when you're young, you know, you make mistakes and you do some stupid stuff.
"I've been hearing a lot about young people who, you know, they're posting stuff on Facebook, and then suddenly they go apply for a job, and ..."
Obama's advice about the perils of modern technology were born of bitter experience, as he has fallen victim to the YouTube age of modern campaign politics several times himself when off-the-cuff remarks or events have shown up on web videos or blogs.
At one stage, his 2008 election campaign was rocked by inflammatory past speeches by his former pastor Reverend Jeremiah Wright which were posted on YouTube.
On another occasion, Obama's words at a private fundraiser that some Pennsylvanians sapped by job losses become bitter and cling to guns and religion, showed up on the Huffington Post blog, causing a political furor.
Obama also sparked a row when video surfaced of him telling a newspaper editorial board that Republican president Ronald Reagan had changed the trajectory of America in a way Democratic ex-president Bill Clinton had not.