If your female is in heat keep her confined from all males during the three week cycle. Confine your female in a shed, garage, or basement. You can also cage a female that is a housedog or lock in another room if there is a male in the house. If your female is in a pen, make sure it is secure. Don't be fooled.
Males can get in.
Believe it or not, there have been cases where a male has actually mated with a female through the fence. When your dog is out, never leave her unattended for a moment. It only takes a minute for a male to mate your female. To discourage males from coming to your house, if possible drive your dog to a vacant field or park away from your home to relieve herself. Also be careful of males wanting to mate.