We like to do more than that, actually. The B-field is an element in the differential cohomology class \check{H}^3(M)$\check{H}^3(M)$, or, more geometrically, a connection on an abelian gerbe. Thus, there is a class [H] \in H^3(M,Z)$[H] \in H^3(M,Z)$ characterizing the gerbe. In the B-model, this twists the derived category. The connection is the part that changes the A-model, and when [H] = 0$[H] = 0$, you exactly get that the differential cohomology group is H^2(X,U(1))$H^2(X,U(1))$. In the geometric language, it's a flat connection on a trivial gerbe.