Allegations of corruption against Mr Erdogan have been repeated on the social media sites.
The leaks included a phone conversation in which, allegedly, he and his son discussed how to hide huge sums of money. Mr Erdogan called it a montage.
His Islamist-rooted AK Party faces key local elections on 30 March.
"We will not leave this nation at the mercy of YouTube and Facebook," Mr Erdogan told the Turkish broadcaster ATV.
"We will take the necessary steps in the strongest way." Asked if that could include barring the social media sites, he said: "Included."
He said the two sites were being used for "all kinds of immorality, all kinds of espionage".
A major corruption investigation has targeted government allies of the prime minister - and he has responded by moving hundreds of police officers and prosecutors to other duties.
Last month the AK-dominated Turkish parliament passed a new law allowing Turkey's telecommunications authority to block websites without first seeking a court ruling. It sparked violent protests in Istanbul.
Mr Erdogan said he had complained to US President Barack Obama about the activities of US-based cleric Fethullah Gulen.
The cleric runs an influential Islamist network, seen by Mr Erdogan as a threat to his authority.