The correct option is B Earth's magnetism
The needle of a magnetic compass gets deflected due to Earth's magnetism. As we all know Earth behaves as a huge bar magnet with its poles aligned to the north and south poles of earth. Due to this magnetism of Earth, the needle of the magnetic compass deflects.