It's usual to use a smaller needle for the ribbing as ribbed sts tend to look larger than they are. Going down 2 sizes is okay, so is just 1 size, so if you have 5s, they'll be fine.
Also, should the number of stitches cast on be based on the gauge for the body or for the ribbing?
That's trickier. The ribbing should stretch enough that if you use the sts for the body gauge it should work. If you use the gauge from the ribbing it could be too small.