You can use a heat lamp, but a regulated under-tank heater (UTH) is generally preferred for corn snakes.
The UTH provides belly heat that aids digestion, while a heat lamp may not effectively warm the entire enclosure.