In practice, they are interchangeable (also "I like walking").
If you are an advanced learner, it's worth understanding the difference in emphasis between an infinitive and a gerund. The former expresses the concept, the idea, the hypothetical nature of the verb, whereas the latter expresses the reality, the active nature of the verb.
I like to walk - emphasises your mental preference
I like walking - emphasises your enjoyment when doing this activity
If you can appreciate this difference, it may help you to understand better why some constructions and some verbs must be followed by an infinitive (e.g. it is necessary to ....) and why some must followed by a gerund (subject + avoid + ing - never avoid + to).