If Hinduism believes in cycle of reincarnation,then when will the person go to heaven(swarga loka)or hell( naraka ),and how and what is moksha?
Gita 9.24: I am the enjoyer and the only Lord of all sacrifices. But those who fail to realize My divine nature must be reborn.
BG 16.21: There are three gates leading to the hell of self-destruction for the soul—lust, anger, and greed. Therefore, all should abandon these three.
BG 9.21: When they have enjoyed the vast pleasures of heaven, the stock of their merits being exhausted, they return to the earthly plane. Thus, those who follow the Vedic rituals, desiring objects of enjoyment, repeatedly come and go in this world. This verse also says about reincarnation.
Katha Up 2.3.14 : When all desires clinging to the heart of one fall off, then the mortal becomes immortal and here attains Brahman.
What is moksha?
The word "Moksha" literally means "liberation" or "librate".
So moksha in Hinduism means liberation from the cycle of life and death.