He is watching the television.
He is watching television.
Both are possible, but I would say "He is watching television" is more common.
I'm writing an essay for Spanish class.
I'm writing an essay for the Spanish class.
Again, both are possible. I would say the first is more common and I would also say "I'm writing an essay for my Spanish class". Note, however, that this could also mean you are a teacher writing an essay for your students!
The second sentence might be misinterpreted as meaning "I am writing an essay for a class of people who are learning Spanish". You would also have had to have previously mentioned the specific Spanish class in order to refer to it as "the Spanish class" here.