Although the German Military Code of Justice which existed throughout the Second World War maintained that, in principle, an order to commit a crime given by a superior officer removed responsibility from the lower ranks for the consequences of that order, it still asserted that action would be taken against the officer giving the order and also against the lower ranks if they either exceeded their orders or knew at the time that they were being ordered to commit criminal acts.
Article 47 of the German Military Code of Justice 1940
"If the implementation of a military order leads to the violation of the criminal law, the commanding officer who gave that order will be the only one held responsible. However, the subordinate who obeys will share in the responsibility and punishment if he exceeds the order or if he should have realized that the order implied an act that was evidently a military or civil crime."
Source: BASSIOUNI, Crimes against humanity in International Criminal Law,1992 pp.421-422
Interestingly, Joseph Goebbels, the Reich Minister for Propaganda from 1933-45, drew on Article 47 of the Military Code in a newspaper article published in May 1944 to justify the murder of Allied pilots by German civilians:
"The pilots cannot validly claim that as soldiers they obeyed orders. No law of war provides that a soldier will remain unpunished for a hateful crime by referring to the orders of his superior, if their orders are in striking opposition to all human ethics, to all international customs in the conduct of war. Orders from a superior do not exonerate the agent of a manifest crime from responsibility. Any other solution would, moreover, be unacceptable, for it would testify to the impotence of all repressive policy.”
Source:The Nikzor Project