It is highly unlikely that this will do any damage at all, any more than, say, if one developed the habit of tucking their thumbs slightly into the folded fingers instead of over them when making a loose fist.
The purpose of the toes is to help us balance on our feet and to aid in pushing off while walking, which has to be done with the toes flat on the floor/ground. If he's walking normally (and you observe normal toe position when he's walking barefoot), I would make no more of it, as function is maintained, and attention to this behavior may be reinforcing it. Also, why worry about what is harmless?
If he actually does this while walking, however (please do tell us if he is; I'd be very curious to know, as I've never seen this), bring this to his doctor's attention. In this case, it would definitely throw off his gait and do some harm to his feet.
Again, I would ignore this myself if he's walking correctly, but if you feel you need to stop him from doing it, keeping him in well-fitting shoes most of the day would prevent this. It would also inhibit him from experiencing a relaxing 'habit' and would frustrate to a degree his sense of autonomy.