There is no medication that can eliminate a male dog's desire for females. However, the behavior can be managed through neutering, which reduces testosterone-driven sexual drive. Training and environmental management, such as keeping the dog away from females, are also effective strategies.
If you are concerned about your dog's behavior, speak with a veterinarian to develop an appropriate management plan.