Barnyard puns are deliberately terrible, and the way to deliver one is to commit to it. Say it with a straight face and wait for the groan; apologizing halfway through ruins it.
They suit country fairs, petting zoos and anyone who grew up around animals. Someone who has actually milked a cow will appreciate a cow pun on a level the rest of us can only guess at.
County fairs, farmers' markets, rodeos, petting zoos and country weddings are the obvious venues, but farm puns travel further than you would think. They are cheerful, clean enough for most company and silly enough that nobody takes them as a serious advance.
Use them on people with a sense of humor about where they come from. A farm kid will happily trade puns with you; someone who has never met a goat may just be puzzled. Either way, keep it to one line per animal before the conversation turns into a petting zoo.