Past perfect continuous tense indicates something habitual or progressive that occurred in the past: "I drank tea because I had been running out of coffee" puts the coffee shortage further in the past relative to the drinking of tea, and means that you were, but are no longer running out of coffee, which implies you have enough coffee now (at the point of time of drinking tea) -- so why is that a reason to drink tea? That makes your sentence illogical from a strict semantic perspective, though your listener will understand your meaning anyway. So the more grammatically appropriate statement would be either
because I was running out of coffee (past continuous: the coffee was not yet completely finished, but stocks were running low)
because I had run out of coffee (past perfect tense)
as the test corrected you.
You can even informally use simple past tense as in "I had a cup of tea because I ran out of coffee" but past perfect is the formally correct option.
Paradoxically, past perfect continuous works if you say it first, as in
I had been running out of coffee, so I drank a cup of tea.
This sentence is correct because the construction puts the process of running out of coffee in the past relative to the point in time of making the statement. Equally correct:
I was running out of coffee, so I drank a cup of tea.
I had run out of coffee, so I drank a cup of tea.
(Informal) I ran out of coffee, so I had a cup of tea.