The easiest remedy for dog hairballs is actually quite simple: grooming. Regular grooming should keep hairballs from occurring in the first place. Grooming your dog frequently will remove all the loose hair from his coat, significantly decreasing the amount of hair your dog might ingest. Even if your dog does continue to lick his fur, he should swallow less hair.
You may also want to teach your dog not to lick the fur excessively in the first place. While it is normal for many dogs to groom themselves occasionally, excessive licking could cause hairballs, skin irritation and skin sores. Speak with your veterinarian or a professional dog trainer for ideas on how to break your dog of this habit. Providing distractions when your dog begins to groom may be the easiest way to break him of the habit.