How can I code in a buzzer while using a 7-segment in an 8051
In order to keep the display driver all the time, you have to ensure that the MCU won't be disturbed by other tasks for significant duration (preset case). For now, the buzzer function is taking complete attention for the whole duration of sound event.   

Please utilise a hardware timer built in which can run independent of what MCU core is executing. When the hardware timer expires, it will interrupt the MCU.   

As @Jonk suggested, you can set the GPIO to drive the buzzer, fire the hardware timer and go back to LCD driving function. This can be done with just a few couple of instructions and should not create a visible pause of the display. When the hardware timer expires, it will create an interrupt. This time, you can turn off the buzzer and return to the display function again.


update the LCD display to show new number
Set the buzzer GPIO and fire the hardware timer with appropriate delay
Once hardware timer interrupts, RESET buzzer GPIO




Only in case of urgent hardware solution:
For now, I would also put a 555 timer for the buzzer control in case th function is needed urgently

Also read,
https://stackoverflow.com/questions/24128864/how-to-achieve-multitasking-in-a-microcontroller