In primary fermentation you need a little bit of headspace for some foaming (it's generally not a thick krausen like beer). In a one-gallon jar, I leave the liquid level about 1" below the the shoulder of the jar, where it starts to narrow to the neck. This leaves the full surface area to offgas CO2 during fermentation.
In secondary, you want as little headspace as possible. I will fill the vessel up into the neck of the bottle. Minimal surface area to absorb O2.