This page of The Last of Us game guide explains how to deal with David. The encounter with the man can be described to some extent as a boss fight, although the man must be defeated by using a specific trick. During the encounter you will not be able to use firearms or explosives.
The encounter with Davit takes place at the end of Cabin Resort stage, or to be more specific during the section in which you will be controlling Ellie.
The girl needs to go through a series of locations with severely limited visibility and finally reach a container that she can climb on. After going through an open window, you will be inside a building. Search through it thoroughly, collecting all of the useful items, and then go through the doors on the right side. The encounter with David will now start.
At the beginning of the encounter your task is to approach the man from behind and stab him with the knife. In order to do this, hide behind the closest obstacle and listen for the enemy's footsteps.
Getting close to the enemy is not a difficult task, although you need to watch out for broken utensils scattered on the floor. Stepping on them will cause David to hear you and rush towards your location. If that happens, you need to quickly run away and hide again. The game is automatically saved each time you stab the enemy - and you need to perform the action three times.
Once you strike the enemy twice, he will stop underestimating you. Instead of walking casually around the area, the enemy will start to sneak as well. The enemy will quickly run from one place to another, after which he will stop for several seconds, hiding behind the nearest obstacle. Your task is to approach the enemy once he is doing that and attack him for the third time. Be careful not to step on the mentioned utensils. The third successful attack on the enemy will end this scene.