Heterocyst function in cyanobacteria and its localization
According to wikipedia :


  Heterocysts are specialized, pale-yellow,thick-walled cells with disputed function nitrogen-fixing formed during nitrogen starvation by some filamentous cyanobacteria, such as Nostoc punctiforme...


Thus by definition these are not within the cells, but differentiated cells themselves.

This is a good paper that can give you details on nitrogen fixation in the cyanobacterium Anabaena variabilis.

In general: cyanobacteria are photosynthetic prokaryotes, and many of them are capable of fixing nitrogen (that is the ability to use and incorporate nitrogen from the air as N2 gas). The enzyme called nitrogenase is oxygen sensitive thus either temporal or spatial separation of nitrogen fixing must be done to avoid damage to the enzmye from oxygen produced by photosynthesis.


  In Anabaena spp., aerobic nitrogen fixation is confined to differentiated cells called heterocysts that form in a semiregular pattern in a filament in response to nitrogen starvation. Fixed nitrogen in the heterocysts is transported to vegetative cells in the filament, while vegetative cells supply carbon and reductant to heterocysts


So as you can see spearate cells work together to supply each other with necessary nutrients. It is important to note that when sufficient fixed nitrogen source is available the number of such specialized formations is low due there is no need for extra nitrogen to be fixed

There are plenty of details on heterocysts and nitrogen fixation in the linked article. Also this paper hold details of regulation of nitrogen fixation and also has a thorough image of the process: