The correct option is
B must
The sentence indicates that the subject has a headache and that he needs to take an aspirin. Thus, the answer must indicate that the subject needs to take an aspirin.
Option A is correct. 'must' means 'necessity or need'. Thus, it indicates that the subject needs to take an aspirin. Therefore, it conveys the correct meaning and is the correct answer.
Option B is incorrect. 'ought' indicates moral obligation and not need. Thus, it does not convey the correct meaning. Further, there must always be a 'to' after 'ought'. Since there isn't in this case, it will make the sentence grammatically incorrect.
Option C is incorrect. 'had to' indicates compulsion and not need. Further, it is in the past tense and the sentence is in the simple present tense. Thus, using it will make the tense of the sentence inconsistent.
Option D is incorrect. 'must have' indicates need but, it is in the present perfect tense while the sentence is in simple present tense. Thus, using it will make the tense of the sentence inconsistent.