Whem dr. Finds small cavity on x-ray, is it necessary to fix right away? Or do I still have two, three months to fix cavity on teeth?

Fix it . I would say why delaying fixing a cavity .. When a dentist sees a cavity in the x rays for sure it should be fixed before it gets beyond fixation and turns into more complicated situation . I.E root canal treatment ...
Active or not? Small inactive cavities called arrested caries can remain present for a long time without progressing, relics from earlier times when diet and home care weren't optimal. If it is a new lesion and there is evidence of active caries in your mouth it should be treated right away. Knowing the difference is a matter of clinical judgement.
cavity...how soon. Any caries found on an xray should be treated quickly it only will get bigger requiring a larger filling which will last a shorter amount of time small fillings, if neccessary are the way to go.