The usual thing to do in this situation is to ask B when they need your response. If that isn't enough time to hear back from A, then it's fine to ask B if you can have more time to decide (you don't need to say why). Of course, they might say that they cannot give you more time, in which case you'll have to make a decision on B without knowing about A.
There's nothing wrong with wanting to consider all your options, and the people from B will undoubtedly read between the lines and understand that this is the situation, but you don't need to rub their nose in the fact that you'd rather be somewhere else.
To echo Pavel's answer, whatever decision you do give to B, you should stick with. If B gives you a short deadline, and you decide to accept their offer before hearing from A, you're committed, and you need to immediately contact A and withdraw your application. It's not appropriate to accept B while planning to back out if A later says yes. Doing that would burn your bridges with people at B (and anyone who they talk to), and it could even be cause for A to rescind your acceptance, leaving you with nothing.