Use
chmod g+s directory
to set the sticky group bit of a directory.
After this, all files created in the directory will have the same group as the directory itself.