Dobby's previous masters were the Malfoys. Harry freed Dobby from them by tricking Lucius into giving Dobby a sock. As Dobby himself said in Chamber of Secrets:
Dobby can only be freed if his master presents him with clothes.
So Dobby considers Harry as his savior and best friend, and owes him a debt. That's different from being indebted to him, though. Dobby has no master after being freed, but still possesses Elf magic. He helps Harry out of friendship.
Kreacher, on the other hand, was Harry's elf, since Harry inherited the House of Black and Kreacher came with it. There is no relation between Dobby and Kreacher, AFAIK, other than both being Elves.
And if you're asking how Dobby found Harry, however...
He was sent to help him by Aberforth, Dumbledore's brother, who kept an eye on Harry through the shard from Sirius's mirror.