Thanks for the additional information.
Herding breeds tend to do this as part of herding people out the door. Nipping at heels is usually how they move sheep and other livestock around. Often smaller dogs who do not feel brave enough to confront people head on, so they tend to wait until the people are leaving and then sneak up on them and attempt to nip them. In their mind it works since they nip or chase after them and the people leave.
This can be corrected but you do need to do training with the dog. Obedience training is best as it can be used to help control the dog and stop the behavior. Even if you don't have the dog the majority of the time, you can still make progress. The following site is helpful in helping owners train their dog. Be sure and click on the link to the page on obedience at the bottom. and links on subsequent pages leading to detailed instructions.
Until your dog is trained, you can leave a leash on the dog and have him sit at the door before they leave. Slip the leash under your foot so the dog can not move. Most don't know "NO" so if he growls, give a little tug to get his attention on you and then a firm NO to let him know the behavior is unacceptable. Conversely, if he doesn't display the behavior, praise him in a calm voice and give him a hot dog sliver as a reward. It usually does not take long for the dog to realize that if they remain sitting and do not growl or lunge, they get a tasty hot dog treat. If you can get someone to help you with this training, it can go quite fast as you have them come in and out until the dog succeeds and get the treat. The repetition helps the dog realize the desired behavior quicker and thus training goes faster.
This is going to take some time, but is the best way of stopping the behavior. Of course, you can also go buy a bastket style muzzle and have the dog wear that when you are taking care of the dog. That will prevent bites. It does need to be the basket style type so the dog can breath normally. Most even allow a dog to drink and eat to a limited degree as well.
I hope this information is helpful to you. If you would like any additional information or have more questions please don’t hesitate to press the reply to expert or continue conversation button so I can address any issues you still have . If you do find this helpful, please take this opportunity to rate my answer positively so I am compensated for my time.