First, an electron has both an electric charge -e and an intrinsic magnetic dipole moment N-S, μ.
Static electricity in the needle means that you rearrange the charges in the needle and you spatially split them in negative region (one end of the needle) and positive (other end of the needle). Negative region is the region which has an excess of free electrons where positive region is the region which has a lack in the number of electrons. This charge imbalance causes the electrostatic charge and field of the needle when rubbing it with a cloth.
However in this kind of charge the magnetic moments of the electrons are randomly scattered in any direction therefore there is no magnetization of the needle thus it CANNOT SENSE and respond to the magnetic field of the Earth.
Magnetostatics are different. Charges (i.e. electrons) are evenly distributed inside the matter of the metal needle. If you can find a way assuming the needle material is ferromagnetic to re-orient all magnetic moments of the unpaired electrons to align to the same direction then you will magnetize the needle and it will sense the magnetic field of the Earth and needle will respond by aligning to the magnetic field of the Earth!
See below illustration of the difference between electrostatically charged matter and magnetically dipole charged matter (i.e. magnetized):
Green arrows represent the magnetic moments N-S direction of the electrons.
It all depends on the material if it is magnetizable or electrostatic chargeable? There are materials that respond both to magnetic and electrostatic charging but eletrostatically charging a material will not make it magnetic and magnetizing it will not make it electrostatic.
Note: Even, when uniformly rubbing the needle with a cloth so that you end up with a uniformly electrostatically charged needle (i.e. the whole needle surface lacks in electrons or has an excess of electrons relative to other material objects), it will still have its charges' magnetic moments randomly oriented and therefore you cannot achieve magnetization of the needle by triboelectric effect. Electrostatic charging is about spatially transferring whole charges from one place to the other. Magnetostatic charging is about turning the charge's magnetic moments so that they face all to the same direction. It's two different things which each requires a different procedure to be accomplished assuming the specific material's atomic structure allows it.
Update 22 Nov 2021:
Although the above answer is describing the general case farther investigation revealed this article I cannot dismiss lightly since in almost every rule there are exceptions and we must be open minded:
Survival Gear: How To Make A Compass
It says: "you can magnetize a needle by rubbing it against your hair, some animal fur, or silk. Carefully hold the sharp point of the needle and rub just the eye of the needle 50 to 100 times against the hair, fur, or silk."
In first glance this may seem ridiculous but there is possibility to both electrically charge in this case the needle and also magnetize it!
This is because it says to only rub the eye, the very tip of the needle. It is possible in such as small volume (less than a few microns cross-section) the electrostatically accumulated charges in there to end up also more or less with aligned magnetic moments in the same direction. Therefore aligned magnetic domains are formed at the very tip of the needle that would act as a magnet.
Only an actual experiment can tell with the needle seeking the Earth's magnetic south pole (i.e. located close to the Geographic North pole).
I expect this magnetization effect to be very small, if any at all, but a needle floating on water, could work.
Update 26 Nov 2021:
I did an experiment linked on the comments below (please read also my related comments below addressed to @Ed Flea, to avoid any misunderstandings). Nothing conclusive unless repeated many times and replicated also by others, although it seems at first glance a positive result.
Update 28 Nov 2021:
Okay, I have repeated this experiment many times now and my results show conclusively that you CANNOT magnetize the eye of a needle by static electricity (i.e. triboelectric effect) as some of these survival guides magazines claim.
The first experiment run I've got a positive result must have been a fluke, somehow accidentally the needle must have been magnetized. I bought some new needles and repeated the experiment 10 times, always with the same result. No magnetization of the needle.
Conclusion: You cannot magnetize a needle by static electricity.
user253751 said, "[electric current] only flows in loops."
That's true, but what that user didn't say is that the electrical grid is connected to Earth in many places. There is a loop from the transformer outside your house, through the "live" wire, through you, through the Earth, through a long metal stake driven in to the ground near the transformer, and back to the transformer.
The grid is grounded like that to prevent atmospheric phenomena (the same that cause lightning) from building up dangerous static charges on overhead wires.
The current to any small appliance in your home is supplied by two wires. One wire sometimes is known as "hot," and the other is known as "neutral." The neutral wire is connected to Earth. If you touch it, then you won't feel anything. The "hot" wire is the one you don't want to touch. The voltage on the hot wire relative to Earth can be anywhere from around 110 V to 240 V depending on where in the world you live.
Best Answer
One can produce static electricity continuously for example by a Van de Graaff accelerator (Look it up in wikipedia) it is used to create a current of fast electrons or other elementary particles trough vacuum. One could theoretically use it for current through resistors. But the efficiency would be very, very low, so it has no practical use.