The production of $B^{pm}$ mesons is studied in $pp$ collisions at centre-of-mass energies of 7 and 13 TeV, using $B^{pm}rightarrow J/psi K^{pm}$ decays and data samples corresponding to 1.0 fb$^{-1}$ and 0.3 fb$^{-1}$, respectively. The production cross-sections summed over both charges and integrated over the transverse momentum range $0<p_{text{T}}< 40$ GeV/$c$ and the rapidity range $2.0<y<4.5$ are measured to be $sigma(pp rightarrow B^{pm} X, sqrt{s} = text{7 TeV}) = 43.0 pm 0.2 pm 2.5 pm 1.7mu b,$ $sigma(pp rightarrow B^{pm} X, sqrt{s} = text{13 TeV}) = 86.6 pm 0.5 pm 5.4 pm 3.4mu b,$ where the first uncertainties are statistical, the second are systematic, and the third are due to the limited knowledge of the $B^{pm}rightarrow J/psi K^{pm}$ branching fraction. The ratio of the cross-section at 13 TeV to that at 7 TeV is determined to be $2.02pm0.02text{(stat)}pm0.12text{(syst)}$. Differential cross-sections are also reported as functions of $p_{text{T}}$ and $y$. All results are in agreement with theoretical calculations based on the state-of-art fixed next-to-leading order quantum chromodynamics.