I thought the War of Jenkins' Ear sounded plausible, but then I looked up Sir Robert Peel and saw that he created the Metropolitan Police after becoming home secretary in 1822, after both the Peninsular War and the War of Jenkins' Ear. Do all versions of the song include the word "peelers"? If so, it was probably written after 1822, though I suppose it could still refer to one of these wars.