Aria Ladjedvardi, aged 21 and with Iranian roots, received a prison term of two years, handed down by the Frankfurt regional court.
The court heard that the man, having been radicalised in Germany, travelled to Syria for at least several weeks in early 2014, where he joined a militant identified only as Vedat V., who remains at large.
In March or April, jihadists including Vedat V. attacked a Syrian army checkpoint near the town of Binnish, Idlib province, captured at least two troops, beheaded them and impaled their heads on metal rods.
“The accused posed with the dismembered heads and let himself be photographed three times, so as to mock and belittle the deceased, whom he considered 'dishonourable infidels'” or non-believers, the court said in a statement.
Vedat V. later uploaded one of the images on Facebook.
The pictures were also found stored on a computer in Germany and on the mobile phone of the mother of the accused, said the court.
Ladjedvardi had earlier told the court he did not want to be in the incriminating pictures, and that he “could not imagine that they would be circulated on social media”.
He admitted that he was given weapons training, but insisted he was not part of any jihadist group throughout his trip to Syria.