Domesticated animals will need a livestock pen to hold 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.