artscroll's commentary on Proverbs/Mishlei brings the source as the verse (20:27)
נֵ֣ר יְ֭הוָה נִשְׁמַ֣ת אָדָ֑ם חֹ֝פֵ֗שׂ כָּל־חַדְרֵי־בָֽטֶן׃
A
man's soul is the lamp of Hashem which searches the chambers of one's
innards
They bring R Bachya (on Shemot 25:31) building on this verse and writing the soul delights in light because it is "a being of light"
It is known that the soul itself benefits when lights are lit and it
derives pleasure and joy from its light. Once the soul is in a joyous
state its joy spreads seeing the soul itself is perceived as if it
were hewn out of the light of man’s intelligence. This relationship
between light and intelligence is the reason why the soul is drawn
after light which is of its own kind although basically the “light” of
our intelligence is essentially physical in nature, whereas the light
represented by the soul is of a spiritual nature. This is why Solomon
was able to compare a lamp (physical light) to the soul (spiritual
light) when he said “the soul is the light of the
Lord.”
Sefer HaIkkarim comments that the analogy between the candle and the soul strengthens our belief in the resurrection of the dead. Just as a candle is easy to relight after it has been extinguished, so too can a soul return to the body.
See also here.