I’d recommend using the Animation or ProRes 422 / 422 HQ codec, keep these as our originals and compress them to H264 or whatever you need after render from AE.
ProRes has the advantage of being a 10- or 12-bit codec compared to Animation being 8-bit and they usually hold visually lossless output. Only having 8-bits of color fidelity can sometimes limit the quality of your output (i.e. you get bandings).
Also, the Apple h264 codec is one of the worst out there. It gets the job done but that’s about it. I’d recommend using something like x264 for QuickTime as a better alternative.