The sentence that is puntuated correctly is the first one:
Despite missing a month of school, Hector's extra work earned him a B in Algebra II.
In this particular example a coma is needed at the end of the prepositional phrase as it is placed at the beginning of the sentence.