When i write a melody over a chord progression, i notice that some of the notes from the melody, form second interval harmonies with the chord notes. Am i allowed, at least as a beginner, to do this or should i try to avoid second interval harmonies in general?
As a beginner, or as an extremely experienced player/writer, you're allowed to do just what the heck you like. There are 'rules' - more like guidelines, or things that are known to work/not work well. It's called theory. But - the bottom line must always be: does it sound good, to you or others?
You cannot make each and every note in a tune match the underlying chord. You'd end up only playing arpeggios! Some notes - sometimes called passing notes - will not be from the chord.
You state 'second interval harmonies', which may mean, say, over a C chord, a D, F or A note for example. There's nothing wrong with those, especially on the unstressed parts of a bar, like beat 2 or 4 in 4/4.
You can certainly use non-chord notes. 'Theory' delights in labelling the various ways of doing this - 'passing notes', 'accented passing notes', 'suspensions', 'unprepared suspensions', 'chromatic passing notes'. Yes, whatever you choose to do, theory has a name for it!
Are you writing melodies over a given chord structure for a music examination? In this case, it might be sensible to stick to chord notes on the main beats of the music, leave the 'in-between' notes for filling in-between the strong beats. Then the most pedantic teacher won't mark you as wrong! If you're TOLD the chord is C, you'd better not write something that changes it to C(sus4) or C(maj7). In real life, you can modify the chords all you like of course.
This just means that your ears develop faster than your knowledge of harmony.
Generally, adding a diatonic second above 1 and 5 sounds well. The only second to watch for is the minor second above major 3 - if your ear tells you it fits the melody, then you should probably make the chord a SUS (which usually means skipping 3rd).