|for /f - A loop that iterates over lines of text that can break the lines up into "chunks"(tokens).|
"tokens=3" - Option telling the for loop that we only want the third chunk of text. By default the delimiters are tabs or spaces, but that can also be changed by using the "delims=" option.
%%a - Variable that the for loop will use, can be any letter and some other characters, it is case sensitive.
in ('sc query "%service%"^|find "STATE"') - What the for loop will run over, it can either be a file, command or string. In this case it is a command. The method of quoting tells the for loop what it is processing, single quotes mean that it is a command unless the usebackq option is present, which changes the semantics. Note that special characters like "|" are prefixed with a caret ^ so their meaning isn't interpreted until the command is executed.
do ( Everything in the code block (or after do if it is a single line) is processed once every line where the variable is swapped for the text from that line.
For more detailed info start>run>cmd>"for /?"(without quotes)