The kind of spirit that is associated with us is determined by the kind of person we are in respect to affection and love, though good spirits are assigned to us by the Lord while we ourselves summon the evil ones. The spirits with us change, however, as our own affections change. This means we have one kind with us in infancy, another kind during our childhood, another kind as we are growing up and in early adulthood, and still another kind in old age. During our earliest years, spirits who are in innocence are with us, that is, spirits who are in touch with the heaven of innocence, the inmost or third heaven. In later childhood we are in the company of spirits who are engaged in an affection for knowledge and who are in touch with the ultimate or first heaven. As we are growing up, during our early adulthood, spirits who are responsive to affections for what is true and good and therefore with intelligence are with us. They are spirits who are in touch with the second or intermediate heaven. In old age, though, spirits who are in wisdom and innocence are with us, spirits therefore who are in touch with the inmost or third heaven.
Still, this association is arranged by the Lord for people who can be reformed and regenerated. It is different for people who cannot be reformed or regenerated. Good spirits are assigned to them as well in order to restrain them from evil as much as possible, but their direct connection is with the evil spirits who are in touch with hell. This means that the spirits are of the same nature as the people they are associated with. Whether they love themselves or money or revenge or adultery, the same kind of spirits are with them and are, so to speak, taking up residence in their evil affections. To the extent that we cannot be restrained from evil by good spirits, they inflame us, and to the extent that an evil affection is in control, they cling to us and will not back off.
In this way, evil people are united to hell and good people to heaven.
from Heaven and Hell, Section 295