In Swedish, we've got a term that loosely translates as paragraph jockey. It refers to a person, often a clerk or a referee, who is following all the rules, prescriptions and agreements ad absurdum. The application is slightly derogatory but not vulgar.
In many cases, the term is used when a referee or a bureaucrat makes a call and, while being correct rule-wise, they miss the point of the system that the said rule is made to support.
The result of such call or decision may vary from non-essential, insignificant changes up to a totally weird and unintended destruction of the greater good.
Is there a term like that in English? My google-fu gave me Jack-in-office but when I wrote that to a friend, they didn't get the point at all.
Best Answer
The other guys already gave you good words for referees and bosses ('stickler', 'jobsworth', 'martinet', 'petty tyrant') although, yeah, 'missing the forest for the trees' is closer to what you mean as far as the letter versus the spirit of the law.
I'll just note (a) that you might think of or refer to someone as a 'stickler for the rules' and tell them to their face not to be one, but you wouldn't usually just say 'you're being a stickler' as a pejorative challenge. It's just not how the term fits into the language.
(b) Since no one else has mentioned it yet, there's a lovely term for a scholarly or religious pedant:
Particularly on the internet, it's rather common to run into people who think being technically correct is the best form of correct... or at least worth affecting in order to farm some of that sweet sweet rep/karma/&c.