Meant to check back and answer this sooner in case nobody else had...
I could very well be mistaken, but it does sound as though it may simply be his beard protruding, which looks peculiar but isn't an injury, as you said it goes back, and isn't always present.
As stated, don't know exactly what the situation is with your fish, but in case:
Not sure of search terms, and just making a hasty Google collection, as what I encountered over a year of rather betta-specific searching is scattered.
The major beard-out-the-gills-thing isn't common, thank goodness, as it's not only unattractive but worrisome to the owner, although it appears to be harmless.
Doesn't look very comfortable, either, although it doesn't SEEM to bother them....
http
/www.bettatalk.com/how_to_sex_bettas.htm
Although the pic there shows a beard just protruding, and I've seen one of mine with a great whack sticking out of what I thought seemed like an inflamed gill.
Luckily, I'd already seen illustrations of this, and had the advantage of knowing that gill interiors are typically red in a healthy fish, which we tend not to notice as they're not ordinarily visible.
Still freaked and worried me, until it finally sorted itself out, I believe it was days later, although may only have seemed that way in retrospect.
(Happened a while back, and occurred soon after I'd got the fish, haven't noticed any such extreme since.)
http
/www.goarticles.com/cgi-bin/showa.cgi?C=1083017
... Although both the male and the female technically have the infamous 'Betta beard', it is really only noticeable on the males. On females, the beard is transparent but can be seen if you know where to look.
The Betta beard is found directly beneath the gill plate cover and is actually a membrane. When the gills of the Betta are closed, the membrane will protrude and be visible. This is when it will look like a beard. The beard is also prominently displayed during flaring.
The beard does not necessarily match the rest of the Betta in color--at least not exactly. ...
http
/www.petfish.net/forum/index.php?topic=70657.0
... Maybe i'm not seeing it in the photo. It just looks like his membrane is sticking out a little bit. My Max's membrane sticks out a little all the time because his was damaged a little bit in the bad water at the petstore, it also gave him fin rot. (don't freak out about fin rot, your bettas fins look perfect.) It doesn't affect Max in the least. The membrane is what sticks out when bettas flare. You'll see their gill covers stand out at a 90 degree angle from their body, they'll make their fins look really big, and the membrane will come out kinda like the shape of a beard. ...
http
/www.flippersandfins.net/faq.htm
This seems aimed at kiddies but skimmed through anyway, looking for illustrations or mention of this beard-blowing-out-the-gill phenomenon;
has a pic down the page - note how red the gill interior is as shown in a healthy betta.
Does this seem similar to yours?
Well below this are pics of flaring, one having quite a flap showing, although ordinarily they later retract...
http
/74.125.113.104/search?q=cache
s_hh...cd=19&gl=ca
http
/whitesquirrelinstitute.com/glesener_betta_lab.doc
...Watch each fin individually to see what it is doing.
Pay close attention to angles of approach:
"broadside" displays involve primarily the unpaired dorsal, caudal and anal fins, making the fish look much bigger along the midline
"frontal" displays utilize the gills covers, the extended red gills (beard-like in appearance), and paired pectoral fins, making the fish look much stouter from the front.
See if you can detect any difference in frequency of these two approaches when displaying to another male versus a female.
Note when each fish first notices the other and how long the various displays continue (pay particular attention to the length of time each male extends his operculum and gills). ...
(As in the case below, a more common occurance is to have the membrane simply cover the gill.
The fish who'd scared me with the big whack of beard hanging out did and stll does have black-appearing gills, which can happen as the result of ammonia burn damage, and as he'd initially surfaced very frequently for air, I'd assumed that was likely the case with this fish.
However, he's fine now, despite the appearance of blackness remaining.)
http
/www.####/index.php?showtopic=23174
... By the way...the "black gills" you were talking about look to me to be his beard instead. The Bettas' beards sit over their gills and are often visible under the gill plates and under the head. If that's the case, there's nothing to worry about with them. Betta beards come in all colors of the rainbow, sometimes with dramatic contrasts against the fish's normal body color. My light-colored lavender/pink female has a dark purple, almost black beard. The iridescent and metallic colors you're starting to notice will most likely become more evident as he feels better, too ...
And another comment
... the beard under his gill plates is normal. my halfmoon cresent blu's beard is alot darker than his blue and white body....lol but it has a bit of clear, that's just how he is. lol ...
Anyway, thought I'd mention as this is something not expected, and I wonder how many people do conclude, when this occurs, that their fish is injured, as I certainly would have, had I not been fortunate enough to have come upon a description of this in my internet travels- although I can't seem to find any now.