Welcome to icliniq.com.
Dental varnish contains fluoride which is anticarious and hence prevents the progression of tooth decay.
Pit caries are very minute and very minimal cavities that are superficially present on the teeth. Pit caries does not require fillings because to do the filling, a little bit of normal tooth structure has to be drilled. So, varnish is preferable in very small cavities like yours.
Rarely, small pit caries seen clinically might have progressed deeply (in a triangular pattern with apex seen outside but broad base deep inside the tooth). Yours might be of this type and hence causing pain.