We use "by" when we talk about the agent that infects us with the disease.
We use "with" when we talk about what we are infected with (i.e., the disease).
Jason's comment and Michael's answer explain this quite well.
However, there is a distinction between the names of the agent and the disease in regards to COVID-19.
According to Mayo Clinic: Coronavirus disease 2019 (COVID-19) In 2019, a new coronavirus was identified as the cause of a disease outbreak that originated in China.
The virus is now known as the severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) .
The disease it causes is called coronavirus disease 2019 (COVID-19) .
Also see CBC News: What we know (and don't know) about the coronavirus outbreak.
The virus that causes the illness is now known as SARS-CoV-2​​​​. The initial symptoms of the illness, called COVID-19 , are ...
So, it is SARS-CoV-2​​​​ that infects you with COVID-19.
I should probably point out that this distinction is not something that the average person really pays attention to (or may be even cares about?).
As Kat says in comments, they may even use the terms interchangeably.
ell.stackexchange.com/users/77766/AIQ
With HIV / AIDS, HIV is the agent and AIDS is the disease(s), so you would say I was infected by HIV and infected with AIDS.
The difficulty (so far) is that coronavirus is both the agent and the disease.
Perhaps there will be a separation later - maybe coronavirus for the agent / virus and COVID-19 for the disease?
Edit (in response to a comment from Jason Bassford):
Jason said the same thing as this at the same time in his comment.
ell.stackexchange.com/users/113990/michael
Since my own comment has gained so much attention in other answers, I thought I'd turn it into an actual answer myself.
The Prepositions With and By Here are the definitions of the senses of the prepositions in use, per Merriam-Webster: With : 6
a —used as a function word to indicate the means, cause, agent, or instrumentality hit him with a rock pale with anger threatened with tuberculosis
she amused the crowd with his antics By : 4
a : through the agency (see AGENCY sense 3 ) or instrumentality of //
a poem written by Keats // death by firing squad // taken by force // happened by luck
I had used agent in my original comment when describing by ; however, that can get confusing because of the multiple senses of that word.
(And note that the definitions here actually use one sense of agent in association with the definition of with , while agency is used in association with by .)
It's perhaps better to express it differently.
When you use with , you are talking about an object or effect that is applied as a result of an action.
→ I was poisoned with arsenic.
When you use by you are talking about the subject or cause of an action.
→ I was poisoned by a criminal.
Putting the two together: I was poisoned with arsenic by a criminal.
The Coronavirus Forget the technical distinction between the virus SARS-CoV-2 and the disease COVID-19 .
Let's just assume that when people talk about the coronovirus they are talking about a single thing.
Going back to the difference between with and by .
Statement:
"I was poisoned with arsenic by a criminal."
Question and answer: "
Who or what poisoned you?" "A criminal.
"
"What type of poison was it?
" "Arsenic."
But coronavirus actually does double duty, playing both semantic roles at the same time.
Statement:
"I was infected with the coronavirus by the coronavirus."
Question and answer: "
Who or what infected you?" "The coronavirus.
"
"What type of infection was it?
" "The coronavirus.
"
This means that both of these are grammatical:
I was infected with the coronavirus.
I was infected by the coronavirus.
Even though the nature of the word coronavirus allows the sentences to often be used interchangeably, there is still a subtle difference between the two upon careful analysis.
ell.stackexchange.com/users/73781/Jason Bassford
One more distinction in use: in addition to referring to the contagion itself, infected by in the passive voice could refer more broadly to how the person was infected.
Infected by means of (something).
This secondary meaning isn't there for infected with .
Julie hadn't left her house for weeks, but was infected by her boyfriend who was an "essential worker" at the local supermarket.
The lab researcher always took extreme care when drawing samples from the test subjects, but was infected by a needle accidentally dropped by her lab assistant.
ell.stackexchange.com/users/40004/BradC
Over 200,000 people infected by coronavirus worldwide
This is just passive voice.
To make sense of it, flip it around:
Coronavirus infected over 200,000 people worldwide
So, once coronavirus infected these people, they had coronavirus; you can now say they were infected with a virus.
I think Jason Bassford's comment is a perfect explanation.
ell.stackexchange.com/users/95947/Cranberry48
I found both these two versions are being used   Infected with coronavirus     Infected by coronavirus    Cambridge Dictionary  gives different definitions for them:   to pass a disease to a person, animal, or plant   for "infected with" and   If a place, wound, or substance is infected, it contains bacteria or other things that can cause disease   for "infected by".  However, I can't distinguish those two meanings. Could someone please give a hint?
Difference between "infected with" and "infected by"
ell.stackexchange.com
<meaning><prepositions>
ell.stackexchange.com/questions/245797
ell.stackexchange.com/users/109190/WXJ96163
We use "by" when we talk about the agent that infects us with the disease and we use "with" when we talk about what we are infected with (i.e., the disease).  With HIV / AIDS, HIV is the agent and AIDS is the disease(s), so you would say I was infected by HIV and infected with AIDS.  When you use  with , you are talking about an object or effect that is applied as a result of an action but when you use  by  you are talking about the subject or cause of an action. “By" refers to the cause in this context and "with" refers to the disease in this context. 
“By" refers to the cause in this context. "With" refers to the disease in this context. 