Arithmeticity for periods of automorphic forms