Luke's a farmer, not a swordsman. He had never held a lightsaber in his entire life until that day. However, he has used rifles before; when he went out looking for R2-D2 on Tatooine, he carried a rifle; when the Tusken Raiders attacked, though, they quickly overpowered him with their melee fighting skill.
It takes many years to become proficient with any melee weapon; the lightsaber is much more dangerous, and requires a strong control of the Force to use effectively against enemies with blasters. Note how in Empire Strikes Back Luke still used a blaster except for when he fought Darth Vader:

(Apparently Lando got Han's clothes, and Luke got his blaster.)
Without intimate knowledge of the weight and balance of a lightsaber, and a greater understanding of how to control the Force, it would have been very difficult for Luke to deflect blaster bolts. Without this important defensive ability, if Luke had tried to kill a Stormtrooper on the Death Star with his new lightsaber, he would have been shot many times before taking his first swing. It was much easier for him to use a blaster, something he was more familiar with.
For a more modern example, look at Finn from The Force Awakens. When the First Order attacks, he asks for a weapon even though he's already holding a lightsaber. Then, using the lightsaber, he kills one guy who wasn't paying attention, before nearly being defeated by another guy with an electrified stick. And Finn is a soldier with melee weapons training.
Oh, and also, sometimes there are places a lightsaber just won't reach:

Never underestimate the importance of range.