In the Lagrangian approach to 2-dimensional sigma models, B-fields and D-branes contribute topological terms to the action of worldsheets of both open and closed strings. We show that these terms naturally fit into a 2-dimensional, smooth open-closed functorial field theory (FFT) in the sense of Atiyah, Segal, and Stolz-Teichner. We give a detailed construction of this smooth FFT, based on the definition of a suitable smooth bordism category. In this bordism category, all manifolds are equipped with a smooth map to a spacetime target manifold. Further, the object manifolds are allowed to have boundaries; these are the endpoints of open strings stretched between D-branes. The values of our FFT are obtained from the B-field and its D-branes via transgression. Our construction generalises work of Bunke-Turner-Willerton to include open strings. At the same time, it generalises work of Moore-Segal about open-closed TQFTs to include target spaces. We provide a number of further features of our FFT: we show that it depends functorially on the B-field and the D-branes, we show that it is thin homotopy invariant, and we show that it comes equipped with a positive reflection structure in the sense of Freed-Hopkins. Finally, we describe how our construction is related to the classification of open-closed TQFTs obtained by Lauda-Pfeiffer.