Boche is a French slang word for ‘rascal’ first applied to German soldiers during World War One, and borrowed during the early years of that conflict into British English.
A definition is given in Songs and Slang of the British Soldier: 1914-1918, edited by John Brophy and Eric Partridge, published in 1930. I have augmented their note.
Boche is the preferred and most common English spelling. Bosche is a rarer English alternative spelling.
The word was first used in the phrase tête de boche. The French philologist Albert Dauzat believed boche to be an abbreviation of caboche, playful French slang for ‘human head,’ very much like English comic synonyms for head such as ‘the old noodle,’ noggin, nut, numbskull.
One of the ways of saying ‘to be obstinate, to be pigheaded’ in French is avoir la caboche dure. The root of caboche in the old French province of Picardy is ultimately the Latin word caput ‘head.’ Our English word cabbage has the same origin, the compact head of leaves being a perfect ‘caboche.’
Tête de boche was used as early as 1862 of obstinate persons. It is in print in a document published at Metz . In 1874 French typographers applied it to German compositors. By 1883, states Alfred Delvau's Dictionnaire de la langue Verte, the phrase had come to have the meaning of mauvais sujet and was so used especially by prostitutes.
The Germans, having among the French a reputation for obstinacy and being a bad lot, came to be named with a jesting version of allemande, namely allboche or alboche. About 1900 alboche was shortened to boche as a generic name for Germans. During the war, propaganda posters revived the term by using the phrase sale boche ‘dirty kraut.’
At the beginning of WWI boche had two meanings in continental French: (a) a German and (b) stubborn, hard-headed, obstinate. Quickly during the course of the war, this French slang word was taken up by the English press and public.
By the time of World War Two, while boche was still used in French, it had been replaced in continental French by other put-down terms, such as ‘maudit fritz,’ ‘fridolin,’ and ‘schleu.’ These three milder pejoratives were common during the German occupation of France from 1941 to 1945.
Terms of disparagement in English during WWII used by British troops were ‘Jerry’ and ‘Fritz’ in the British army and navy, and ‘Hun’ in the RAF. Canadian and American troops generally preferred ‘Heinie,’ ‘Kraut’ or Fritz.
(nod to Classic Canadian)