The correct option is
C had worked
In the given sentence, 'was' and 'realized' indicates that the tense of the sentence is past tense. Also, the sentence indicates that the action in the blank had already been complete with respect to the past after which the subject had the realization. Thus, the answer must be in the past perfect tense to indicate an action completed with respect to the past.
Option A is incorrect. 'worked' is in the simple past tense and not the past perfect tense. Thus, using it will make the tense of the sentence inconsistent.
Option B is correct. 'had worked' is in the past perfect tense. Thus, it indicates that the action of working had been completed with respect to the past. Thus, it is correct.
Option C is incorrect. 'has worked' is in the present perfect tense and not the past perfect tense. Thus, using it will make the tense of the sentence inconsistent.
Option D is incorrect. 'has been working' is in the present perfect continuous tense and not the past perfect tense. Thus, using it will make the tense of the sentence inconsistent.