As a kind of non-Newtonian fluid, the Oldroyd-B fluid has widespread applications. To study the flow characteristics deeply is of great significance. In this paper, we consider a simple model of the Oldroyd-B fluid flow over a semi-infinite plate in a magnetic field. The governing equation is formulated, and the numerical solutions are obtained using the finite difference method. To deal with the semi-infinite region, the artificial boundary method is applied to construct the absorbing boundary condition (ABC) with the (inverse) z-transform, which converts the semi-infinite region to a finite one. To test the accuracy of the numerical scheme, a numerical example by introducing the source term is presented. Graphs show the rationality of the ABC by comparing the fluid flow velocity between the direct truncated boundary condition and the ABC. The effects of the amplitude, the frequency, the relaxation time parameter, the retardation time parameter, and the magnetic field on the magnitude and the cycle of flow velocity are investigated and discussed. The main findings are that the retardation time parameter promotes the velocity of the fluid flow, while the relaxation time and magnetic field hinder the fluid flow. When the relaxation time is equal to the retardation time, the Oldroyd-B fluid can approximate the Newtonian fluid. In addition, the oscillating cycle becomes shorter for a smaller relaxation time parameter or a larger magnetic field and frequency.