This varies by state and jurisdiction. In most U.S. states, a licensed electrician is required for electrical work, but the majority of states have a homeowner exemption - if you own and occupy the residence, you can do your own electrical work with a permit. The permit requirement doesn’t go away though - the homeowner exemption covers who can do the work, not whether it needs to be inspected.
Some states don’t allow homeowner electrical work at all. Always verify with your local building department - not the internet, not this forum, the actual AHJ - before starting.
Even where the homeowner exemption exists, many localities restrict it to your primary residence. And the work still has to comply with code - the inspector doesn’t care if you’re a homeowner or a professional. Common DIY failures: no permit pulled, wrong wire gauge, outlets not grounded, GFCI not installed where required, improper panel work. If in doubt, hire it out - an electrical fire is not worth the $200 you saved on labor.