Topological phases in a two-dimensional lattice: Magnetic field versus spin-orbit coupling