Pedalling is very much an art form and it varies a lot how you pedal depending on the musical style you are playing in.
A few beginner rules of thumb to get you started:
- are you familiar with chords yet? everytime the accompaniment changes from one chord into another, for example from C major to G major, is a good time to change the pedal
- if you have melody notes that are close together on the keyboard, it could be a good time to change or avoid pedal all together, otherwise the melody notes mush together and it doesn't sound very harmonious. For example, beginning of Fur Elise goes E D# E D# E B D C A - especially on the ED# part it's better to not have pedal, it'll sound dissonant to have those notes mix together in pedal resonance.
Overall, your goal is to not have "dirt" in the resonance created by the pedal. Dirt is created by mixing together several chords that don't sound harmonious when they sound simultaneously, or melody notes that don't sound harmonious when they sound together. Experiment, use your ear and see if you can notice this!
In more advanced scenarious and certain styles, these rules no longer apply.