…ようか…まいか and …ようが…まいが have different meanings. The fact that they have the same English translation “whether … or not” is bya coincidence.
The English expression “whether … or not” havehas two different usages: (1) as a noun clause, and (2) as an adverbial clause. For example:
(1) I wonder whether I will write to her or not.
(2) I will go to New York tomorrow whether it rains or not. (= I will go to New York tomorrow no matter whether it rains or not.)
…ようか…まいか means (1), whereas …ようが…まいが means (2). Therefore, possible translations of the two sentences above are:
(1) 彼女に手紙を書こうか書くまいか迷う。
(2) 明日、雨が降ろうが降るまいがニューヨークに行く。
(But I think that in (1), …ようか…まいか puts a heavy emphasis on the “whether … or not” part. A usual way to say (1) without this emphasis is 彼女に手紙を書くかどうか迷う.)