It is illegal for the keeper to pick up the ball if a player on his team kicked the ball to him. On the other hand, he can pick it up if the player headed the ball to him instead.
This is not considered a “backpass” offence.
However, by attempting to circumvent the restriction on the goalkeeper handling the ball after it has been deliberately kicked to him by the defender, the defender has committed an act of trickery. It is irrelevant as to whether the goalkeeper ends up handling the ball.
As soon as the defender heads the ball towards the goalkeeper, play should be stopped and the defender should be cautioned for unsporting behaviour. The restart is an indirect free kick to the opponents from where the defender was standing when they headed the ball towards the goalkeeper.
The relevant section in the 2014/15 FIFA Laws of the Game is on p. 123:
Cautions for unsporting behaviour
There are different circumstances when a player must be cautioned for
unsporting behaviour, e.g. if a player:
- uses a deliberate trick while the ball is in play to pass the ball to his own
goalkeeper with his head, chest, knee, etc. in order to circumvent the Law,
irrespective of whether the goalkeeper touches the ball with his hands or
not. The offence is committed by the player in attempting to circumvent
both the letter and the spirit of Law 12 and play is restarted with an indirect
- uses a deliberate trick to pass the ball to his own goalkeeper to circumvent
the Law while he is taking a free kick (after the player is cautioned, the free
kick must be retaken)