A photo was posted online of the 29-year-old - who has three caps - before a game for club side Persepolis.
Iran has strict clothing laws and ISNA news agency said the penalty was for "inappropriate conduct".
The Iranian football federation's morality committee cited Makani's clothing as one reason for the ban.
The photo was initially posted on social media on 6 May, causing the country's media to liken Makani's trousers to the American animation character.
The ruling is not final and can be appealed, but could also be related to a previous controversy in January.
Then Makani, who played for Iran at the 2014 World Cup, was arrested and taken to Tehran's Evin prison after pictures of him in the presence of a woman were leaked.
Iran also has strict laws against the mixing of unrelated men and women.
Subscribe to the BBC Sport newsletter to get our pick of news, features and video sent to your inbox.
Iran goalkeeper Sosha Makani has been suspended for six months after wearing what was described as SpongeBob SquarePants trousers.