In bees, royal jelly and other environmental factors play a role in making these "epigenetic" modifications, and it is likely that the same holds true in ants.
While royal jelly is said to have health benefits for many, it can produce an allergic reaction that could be extreme, and, in rare cases, cause death.