Why oxidation number of oxygen in OF2(oxygen difluoride) is +2?
Oxygen is an electronegative element -True. 

But oxygen is not the most electronegative element. It has an electro negativity of 3.5 on Pauling scale. That means if oxygen combines with an element which is more electronegative than it will surely possess a positive oxidation state.

Fluorine being the most electronegative element (electro negativity of 4.0 on Pauling scale) will in any case (except in fluorine gas) have an oxidation state of -1. So that's the reason why oxygen has a +2 oxidation state in OF2.

Dioxygen difluoride (O2F2) is another fluoride of oxygen in which oxygen has an oxidation state of +1. 

EDIT: Fluorine in its gaseous form (F2) has zero oxidation state.