The Interior Ministry said Suleiman bin Abdullah had been found guilty of kidnapping a male child, tying him up "and performing the obscene" act.
Authorities carried out the sentence against him in Buraydah city, northwest of Riyadh, the ministry said in a statement carried by the official Saudi Press Agency.
He was the latest of 84 Saudis and foreigners to be executed in the kingdom this year, according to an AFP tally.
Rape, murder, drug trafficking, apostasy and armed robbery are punishable by death under Saudi Arabia's strict version of Islamic Sharia law.
Saudi Arabia had the third-highest number of recorded executions in 2013, behind Iran and Iraq, Amnesty International said in a report released in March.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ