We present results of two-dimensional fully kinetic Particle-In-Cell simulation in order to shed light on the role of whistler waves in the scattering of strahl electrons and in the heat flux regulation in the solar wind. We model the electron velocity distribution function as initially composed of core and strahl populations as typically encountered in the near-Sun solar wind as observed by Parker Solar Probe. We demonstrate that, as a consequence of the evolution of the electron velocity distribution function, two branches of the whistler heat flux instability can be excited, which can drive whistler waves propagating in the direction oblique or parallel to the background magnetic field. First, oblique whistler waves induce pitch-angle scattering of strahl electrons, towards higher perpendicular velocities. This leads to the broadening of the strahl pitch angle distribution and hence to the formation of a halo-like population at the expense of the strahl. Later on, the electron velocity distribution function experiences the effect of parallel whistler waves, which contributes to the redistribution of the particles scattered in the perpendicular direction into a more symmetric halo, in agreement with observations. Simulation results show a remarkable agreement with the linear theory of the oblique whistler heat flux instability. The process is accompanied by a significant decrease of the heat flux carried by the strahl population.