use a magnetic compass which points along magnetic field lines, so will point towards the south pole
use a bar magnet with known poles. opposite poles attract and like poles repel so, bringing the bar magnet close to the electromagnet, you can detect which pole is which
How to reverse the poles of an electromagnet
wrap the coil around in the opposite direction
reverse the connections on the cell or power supply