Both are correct.
In a dialogue, a pause can be used for effect, putting emphasis on the greeting, eg:
Hello, Mr. Black.
"Hello" is said first, then a pause, then the name. Normally, people would say:
Hello Mr. Black.
Without any pauses in their speech.
When writing a letter or email, it is quite common to do this:
Hello Mr. Black,
Bla bla bla...
Or in a more formal situation:
Dear Mr. Black,
Bla bla bla...
It is uncommon to put a comma before the title even in an informal email salutation (though quite acceptable), but it would never be done in a formal letter/email.