Update 1:
Because my question is not clear, so I post second example

Because row
Assuming that you want a solution with more than 3 columns, this formula will return you the right header.
I assume that you data starts in row 2, column B - and row 1 contains the column headers.
Use this formula in B1 and copy it down:
=IF(COUNTA($B2:$D2)=0,"",INDEX($B$1:$D$1,MATCH(FALSE,INDEX(ISBLANK($B2:$D2),0),0)))
If your data extends further than column D, simply change this in the formula.