The Real Madrid centre-back scored Spain's opener in the 29th minute from the penalty spot before running to one of the TV cameras behind the goal to perform a glasses gesture by cupping his eyes with his fingers.
German referee Deniz Aytekin showed a yellow card to Ramos as he believed he was trying to provoke the crowd.
"It's been a misunderstanding," Ramos told Spanish TVE after the game. "It was for my nephew, who like me now has to wear glasses. I dedicated the goal to him in order to let him know that it's OK to wear glasses.
"It was a gesture meant for the cameras and not directed to the stands as the referee interpreted."
Aytekin later apologised to Ramos, according to the player.
"I spoke to him [Aytekin] and explained," Ramos said. "He understood and apologised after. I know with so much noise, it's difficult to interpret a gesture but once he knew the reasons behind it, it was easier."
Spain coach Robert Moreno also spoke to Ramos, who converted his 10th penalty of 12 attempts for his country in Bucharest to help Spain clinch their fifth qualifying group stage victory and remain perfect in their Euro 2020 qualifying campaign.
Moreno said in a news conference: "Ramos explained to me that he made that gesture to the camera because his nephew has to wear glasses and he didn't intend to offend anyone."