The direction of the deflection of a magnetic needle is given by
clock rule
The direction of the deflection of a magnetic needle is given by Ampere's swimming rule. Imagine a person swimming along a conductor in the direction of current facing the magnetic needle. The north pole of the magnetic needle deflects towards his left hand.