White balance needs demosaiced data to work. Actually, you could white balance raw data using just multiplies on the pixels that represent red, green and blue, but most modern white balance doesn't work on a simple multiply.
Modern white balance uses a 3x3 matrix, so you need to know the RGB for each pixel. That means it must be a post-demosaic process.
Normally the order of operations is:
linear raw data
demosaic - in software, usually a highly adaptive algorithm
white balance - 3x3 matrix
conversion to output colour space - 3x3 matrix
tonal mapping / curves - look up table
All the 3x3 matrices used can be concatenated together.
You can actually do more than the above, but that's the simplest that works and works well. (I write RAW conversion software BTW.)
Graeme