You can never leave your puppy alone for long periods of time because they are much likely to develop anxiety that is difficult to deal with in a short time.
You can teach your puppy how to deal with your temporary absence by leaving him alone in a room and walking away. A couple of minutes later, return the room without any contact with him. When you repeat the process a few times, try to expand the absences to 30 minutes. If he starts to get irritated and bark or scratch at the door, you should shorten the absence time period.
Try to use some simple tips to calm down your puppy before you are going to leave.
Play with him in advance to consume his excess energy before you leave.
Try to distract his attention by providing him with a meal of puppy food or a puzzle toy for food, so he won’t focus on your absence.