As the other answer indicates, after the Russian Revolution, the Bolsheviks drew Russia out of World War I. This freed up German resources to concentrate on the Western front but, as the other answer aptly states, didn't directly have a great influence on the war.
The Germans had started the war expecting a quick victory. They, therefore, had not prepared for the long war that ensued. Because of this, they made few provisions for securing the food supply, which dropped by 1916 to starvation levels due to fewer crops being harvested (the men were off fighting the war) and due to the effective English blockade of German ports. In addition, casualties were very high, and the German populace increasingly restive about the poor progress of the war and the suffering it was causing.
The communists in Germany were very much inspired and aroused by the stunning Bolshevik victory in Russia and thought this was the moment when, in similar circumstances of great unrest over an unpopular and mismanaged war, they could bring revolution to Germany. They almost did. It was this fear by the German government of falling into the hands of the communists that led to what was later characterized as the "backstab" of the surrender.
The communist contribution to the end of the war was indirect, but it went, in summary, as follows: the revolution was successful in Russia, ending the war there. This had the twofold effect of inspiring the German communists to capitalize on the moment and push for a revolution and the German elites to panic in terror that the communists would succeed, as they just had in Russia. This led to their surrender so that they could stabilize the situation at home. Unfortunately, the Versailles Treaty was so harsh and humiliating that the German situation never did stabilize completely, Hitler eventually took over, and World War II followed.