Your description fits Bruce Sterling's 1982 short story Swarm almost exactly. The story can be found in his collections Crystal Express and Schismatrix Plus.
From the Wikipedia entry for Swarm :
The Shaper Captain-Doctor Simon Afriel arrives on an asteroid in
another solar system to study a colony of a non-intelligent species
known as the Swarm. Their society has an insect-like hierarchy with a
queen and different castes, and also hosts some degenerated alien
species known with a common name as symbiotes which lives as parasites
or in commensal relationships with the others.
Afriel plans to
stay for two years and study it, together with another Shaper called
Galina Mirny who was already there. Their intentions is partly to
prevent the Mechanists to benefit from it, and partly to find a way to
use the hive pheromones to control and manipulate the species, so they
can establish a colony in their own solar system and make them work
for them.
Once on-board the hive seems to take no notice of the
visitors. But when they start to experiment with artificial
pheromones and create a chemical imbalance it triggers the colony's
instinctive mechanisms, who recognize it as a sign of the presence of
intelligence.
From Bruce Sterling's Swarm, near the end:
“I find myself awakened again,” Swarm said dreamily. “I am pleased to
see that there is no major emergency to concern me. Instead it is a
threat that has become almost routine.” It hesitated delicately.
Mirny’s body moved slightly in midair; her breathing was inhumanly
regular. The eyes opened and closed. “Another young race.”
“What
are you?”
“I am the Swarm. That is, I am one of its castes. I am a
tool, an adaptation; my specialty is intelligence. I am not often
needed. It is good to be needed again.”