I needn't have gone to work (was unnecessary, still I did) I did not need to go to work (was unnecessary, not inferable if I did) -- These are different because you have set them in different tenses. The appropriate comparison is between I needn't go to work and I did not need to go to work -- which have the same meaning. You needn't be 18 to be allowed to enter this club.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.