The past perfect continuous tense states an action that was going on in the past up until a certain period of time "run for a long time".
Option B: 'Had been running' is in the past perfect continuous tense. It describes an action that was going on for a certain period of time in the past. It is relevant to the sentence in meaning: the action 'to run' happened for 'a long time', hence it was continuous.
Hence option B is correct.
Option A: 'Have been running' is in present perfect continuous tense and states a continuous action in the present.
Option C: 'Will be running' states a future action.
The tenses do not refer to past actions. Hence options A and C are wrong.
Option D: 'Ran' is a simple past tense verb. It describes an action that happened in the past. Since the action 'was out of breath' is already in the simple past tense, the action that happened before that would not be in the simple past tense, but in a perfect tense, as the action has already completed.
Hence options A, C and D are incorrect.