In this paper, we study the influence of the Aharonov-Casher effect and of an external electromagnetic field on the relativistic and nonrelativistic energy spectra of the (3+1)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(3+1)$$\end{document}-dimensional Dirac oscillator (DO) with magnetic dipole moment in two different scenarios: the Minkowski spacetime (flat case) and the cosmic string spacetime (curved case). Solving the DO, we first determine the flat relativistic spectrum, where we verified that such a spectrum depends explicitly on the magnetic energy Em\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E_m$$\end{document}, quantum numbers n and l, quantum phase phi AC\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\Phi _\textrm{AC}$$\end{document}, and of an effective frequency omega\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\Omega$$\end{document}, on which it depends on the frequency of the DO, given by omega\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega$$\end{document}, and of a type of cyclotron frequency, given by omega AC\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega _\textrm{AC}$$\end{document}. So, due to the presence of the quantum phase, we note that the spectrum is a periodic function with periodicity +/- 2 pi\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\pm 2 \pi$$\end{document}. Besides, the function of Em\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$E_m$$\end{document} is to decrease or increase the energies depending on the choice of spin, while the function of omega AC\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\omega _\textrm{AC}$$\end{document} is to increase the energies of the particle and decrease those of the antiparticle. Solving the DO again, but now in the cosmic string spacetime, we determine the curved relativistic spectrum, where some terms have been modified due to the deficit angle eta\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\eta$$\end{document} (curvature or topological parameter) of the cosmic string. We note that this deficit angle has the function of breaking the degeneracy of energy levels as well as increasing the values of such levels. Finally, we also analyzed the nonrelativistic limit of our results, and comparing our problem with other works, we verified that our results generalize some particular cases in the literature.