Find the distance at which the flashlight no longer causes the compass to deviate from north. This would be the safest and best distance.

If that's not possible, you could remagnetize it to ensure accuracy with a little preparation and testing ahead of time:

From: http://www.dowlingmagnets.com/aboutmagnets.php

Quote:
How do I repair my de-magnetized compass?
If your compass becomes demagnetized (points in the wrong direction), place the South Pole of a magnet directly on top of the compass needle. Slowly slide the bar magnet along the red side of the needle, toward the pointed end, and then down the side of the compass. Pull the magnet away and your compass is re-magnetized.

Is there a simple way to tell which end of a magnet is the north pole?
Both poles of a magnet look the same. However, if you place a compass near a magnet, the needle that normally points toward the north pole of the earth moves in the direction of the magnet’s south pole.


If you determine and mark the flashlight magnet's south pole, you've just added a compass repair magnet to your kit! Also, you could use it to magnetize a sewing needle to hang by thread or float on a leaf in water, and you'd know which end pointed north. cool
_________________________
Bushcraft Science: It's not about surviving in the wilderness, it's about thriving in the wilderness.