Best way:
In person with careful wording. There is no need to put the other person down or to make them feel attacked. Let the person down easy, but don't leave them wandering, so also let them know the reasons, but in the nicest way possible.
Worst way:
Social Media. I've actually seen this done... Instead of even telling the person, some girl I added on facebook just changed her relationship status and tagged the guy in the comments.
Long distance however would provide an acceptable reason for using social media (in private messages of course) or texting. However, the best possible way would be a phone call with the same rules of thumb as the in-person.