Hi Kyouko,
There can be a slight difference.
"Once a XX" means something that happens every XX (period of time). For example, if a food fair is organised once a year (annually), this means that it takes place twice in two years. As you can see, "once a XX" is used when something recurs regularly.
If something happens more than once every XX (period of time), we can indicate the [number of times] it occurs in the expression. Examples: We used to eat out [three times] a week. OR We used to eat out [thrice] a week.
========================================================================================
"Once in a XX" means something that happens only one time within a period of XX. It can be used to express something infrequent. Examples: He used to pamper me with flowers [once a week], but now he does that only [once in a year].
As a side discussion, you may have heard of expressions such as "once in a blue moon" (meaning something very rare or unlikely has happened) and "once in a lifetime". Examples: I will accept this offer as it is a once-in-a-lifetime opportunity.
If you are referring to something that happens once during a longer period (e.g. two weeks, three months, two years), you can use "once in two weeks", "once in three months", "once in two years" and so on. On the contrary, you cannot use "once a three months", "once a two years", "once a two years" and on. This is a difference between "once a XXX" and "once in a XXX".
Again, as a side discussion, to avoid all these hassle, you can also choose to write or say "once EVERY two weeks", "fortnightly", "quarterly", "biennially" and so on.
I hope this helps you.