Depends on where the foam is coming apart I would guess..
My Anons have 3 layers of foam and the outer layer is coming off. I would assume hot glueing the outer layer would case a hard spot to form, therefore rubbing my forehead off. But if the base layer of foam that's attached to your goggles themselves is peeling, hot glue should work for that.
You would need some sort of extremely flexible and thin setting glue for the outer layer.... Maybe an epoxy?
Then your probably golden with using a hot glue gun. Just be careful not to put to much on..... You might actually be able to see the marks where they originally glued the foam on and kinda go by that.
I have used auto body trim glue . It stays flexable and bonds well to all plastics.You could also try something like shoe goo.If you use hot glue make sure it is exterior sticks because the interior sticks release when the get wet.