A measurement of the beauty production cross section in ep collisions at a centre-of-mass energy of 319 GeV is presented. The data were collected with the H1 detector at the HERA collider in the years 1999-2000. Events are selected by requiring the presence of jets and muons in the final state. Both the long lifetime and the large mass of b-flavoured hadrons are exploited to identify events containing beauty quarks. Differential cross sections are measured in photoproduction, with photon virtualities Q^2 < 1 GeV^2, and in deep inelastic scattering, where 2 < Q^2 < 100 GeV^2. The results are compared with perturbative QCD calculations to leading and next-to-leading order. The predictions are found to be somewhat lower than the data.A measure...