The 2022 World Cup winner with Argentina allegedly tested positive for Terbutaline in October 2022, a drug taken to calm bronchospasms.
His club Monza released a statement confirming the sentence from the Spanish Anti-Doping Commission, as the offence occurred while he was at Sevilla.
During his time with the Spanish side, Gomez became a Europa League winner, defeating Roma in the final with a penalty shoot-out win in Budapest.
And now Roma manager Mourinho has aimed a dig at the 35-year-old, despite him not featuring in the final.
Speaking fresh after a 1-0 Serie A win over Roma, Mourinho told the press: "He didn't play the final against us, but the semi-final against Juventus and he already knew about the positive test.
read more on jose mourinho
Jose Mourinho calls himself 'daddy' in hilarious Instagram comment on Chelsea reunion
Jose Mourinho facing 'match to save Roma job' after dreadful start to the season
"I have a cough, but I won't take that syrup. Then maybe they'll find me positive…"
Mourinho's cough syrup joke referred to Gomez's reasoning for the failed test, which he has since put in a statement.
Posting on his social media channels, the former Atalanta player said: "As a result of the recent news published about me in relation to a possible regulatory violation regarding anti-doping, I now inform the media and public opinion of the following:
"1. First of all, I confirm that yesterday I was notified of the decision of the Anti-Doping Sanctioning Committee of the Spanish Commission for the Fight against Doping in Sports, by which the suspension of my federative licence for a period of two years is agreed.
Most read in Football
Man City condemn 'offensive chants' about Sir Bobby Charlton following his sad passing
Sheffield United fan runs onto side of pitch to mock Alejandro Garnacho for diving
Harry Maguire pays tribute to Bobby Charlton after MOTM display and Ten Hag praise
Man United fans boo Ten Hag decisions but Diogo Dalot shuts them up with scorcher
"2. I have always not only strictly complied with all regulations but I have positioned myself as a strong defender of clean sport and sportsmanship, categorically condemning and rejecting all forms of doping.
"3. I have never had nor will I intend to resort to a prohibited practice.
"4. The alleged violation has its origin in the presence of Terbutaline in my body due to having mistakenly and accidentally, involuntarily and unintentionally received a spoonful of my little son's syrup, to relieve his cough. However, it is worth specifying that the therapeutic use of Terbutaline is allowed for professional athletes and that in no case does it improve sporting performance in football.
"5. Without going into substantive issues, I have put this matter in the hands of my lawyers considering that the processing of the disciplinary file would not have been carried out in accordance with the provisions of the regulations.
"6. Finally, I want to thank all the expressions of affection and support received in these difficult moments on a professional level."