First of all you have to tell us whether the distance is desired in a straight air line (as drawn like a ruler) or do you want to measure along streets or ways in the OSM data?

The first option is a matter of geometry, for street routing look at http://wiki.openstreetmap.org/wiki/Routing