Until judgment is given upon the action, the officer before whom such party is brought may either commit such party to the custody of the sheriff of the county in which such officer is, or place him in such care or under such custody as his age and other circumstances require.