Domesticated animals will need a livestock pen to hold them.

Domesticated animals don't consider Livestock Pens and will wander off so it is advisable to put a Fence around them or Herders will have to continually go fetch them.

A Fence and fence gate will stop domesticated animals, but beware that it won't keep any enemies out. However there is no obligation to use a Fence, an ordinary wall (or other block) can be used but must be built two blocks high to keep in animals. While this will cost more resources it will also keep out enemies with the exception of Spiders.

Livestock Pens, like all designations, do not require any construction and can be removed by selecting a Livestock Pen while in the designation menu and holding Alt+Shift.