Do physicists have yet any idea how quarks were formed?
There are competing theories and no definitive answers for when most quarks in the universe formed. The net number of quarks less antiquarks divided by three is called baryon number and that quantity is a conserved quantity in the Standard Model except for what are known as sphaleron processes at very high (first few moments after the Big Bang) temperatures of 10 TeV.
Sphaleron processes, moreover, aren't a sufficient mechanism to get the universe from a zero quark, pure energy state at time=0 which is what many cosmologists like to assume the early universe was like out of aesthetic considerations. But, if those are the initial conditions, then there must be some kind of baryon number violating high energy process that is new physics out there to create more quarks than anti-quarks in vast numbers, because we can't otherwise explain the baryon asymmetry of the universe (i.e. the very lopsided excess of matter atoms over antimatter atoms).
All processes other than the sphaleron process create new quarks and new anti-quarks in equal amounts.
When did that happen, before BB?
Well, we know it took place mostly before Big Bang Nucleosynthesis, because quarks had mostly turned into protons and neutrons by then. And, in a time=0 at the Big Bang cosmology, that doesn't leave a lot of time to get the job done.
Bounce cosmologies don't assume that the current Big Bang started at a pure energy state, so it may have had non-zero baryon number which is more consistent with observation.
Can they be produced at any time in the present? In what
circumstances?
Particle colliders create quark-antiquark pairs on a daily basis and annihilate them, in large numbers that are very well understood mathematically. Virtual quark-antiquark pairs are created and destroyed constantly almost everywhere.
But, these interactions conserve baryon number, so the net number of quarks less antiquarks in the universe remains exactly constant.
Can/are they converted into energy?
Annihilation of quarks which are identical in all respects except their quark-antiquark character can give rise to high energy photons or gluons converting them into energy. But, in practice this rarely happens so cleanly because quarks are "confined" in quark-gluon composite particles called hadrons rather than drifting about freely by themselves.