Researchers have investigated the metabolism of smokers who have stopped smoking. They compared two groups: One group who merely stopped, and one who took nicotine as a replacement. The nicotine group had a higher metabolism when they exercised, but when both groups rested the difference in metabolism was less and was under what they had when they smoked.
This is probably the reason why smokers who stop often go up a few kilo. Anyway, it is always best to stop smoking as this is far more dangerous for health than an increase in weight.
You ask for advice on how to avoid going up in weight when you stop smoking and I suggest that you exercise more, e.g, walk for an hour a day or take some other exercise which you like. Exercise helps to prevent a weight increase in several ways. Some energy is used directly for the exercise, some is used to build up the body so that it gets more muscles where the metabolism is higher than in fat. Furthermore, most people feel less hungry if they exercise in moderation every day. It seems that exercise helps the body's natural hunger regulation system function better. It is also often much easier to achieve a slimming objective with daily exercise.
To stop smoking, or, to stop any other addiction, is extremely difficult. As the body demands immediate satisfaction of its needs, it very easily happens that one form of addiction is replaced by another. Many previous smokers feed themselves chocolate, or any other food, as long as they can stay off cigarettes. There is therefore a risk that a problem of overweight will be created.