You are mistaken. The endings '-og' or '-eg' are the endings of masculine GENITIVE adjectives (singular form) (the same endings are usual for masculine ACCUSATIVE adjectives (singular form) of animate objects). And the endings of masculine DATIVE adjectives (singular form) are '-om' or '-em'. Nevertheless the rule of choosing the endings is the same for all these cases.
You have to choose the endings '-em'/'-eg', if the adjective stem has on its end the following letters: j, lj, nj, ć, đ, ž, š, č. Otherwise you have to choose the endings '-om'/-og.
EXAMPLES:
moj novi prijatelj (my new friend)
naš bivši student (our former student) (the adjective stem has on its end "š")
Genitive:
Evo mog novog prijatelja! (Here is my new friend!)
but
Evo našeg bivšeg studenta! (Here is our former student!)
Accusative:
Vidiš li mog novog prijatelja? (Can you see my new friend?)
but
Vidiš li našeg bivšeg studenta? (Can you see our former student?)
Dative:
Daj knjigu mom novom prijatelju! (Give the book to my new friend!)
but
Daj knjigu našem bivšem studentu! (Give the book to our former student!)
Well, it is rather easy. Is it clear now?