A needle was a sharp thin tool. It was used to weave fabric together to create garments and also for various medical purposes such as injecting drugs before hyposprays and taking blood, and along with suture material, to bind together body tissue after an operation or injury.
The idiom "needle in a haystack" referred to something being difficult to find or do. Miles O'Brien occasionally used the term, as did Jadzia Dax once. (TOS: "The Galileo Seven"; TNG: "The Naked Now"; DS9: "Battle Lines", "Whispers", "Blaze of Glory")
The pointer on a compass was also called a needle. In 2373, Kathryn Janeway compared B'Elanna Torres' plan of polarizing a subspace instability to make a wormhole reappear to making a compass needle move with a magnet. (VOY: "False Profits")
While in the year 1930, the delusional Doctor McCoy rambled on about the inadequacies of 20th century medicine, stating, "they used to hand-cut and sew people like garments. Needles and sutures, all the terrible pain!" (TOS: "The City on the Edge of Forever")
In 2267, Chekov complained to Sulu about all the medical tests he was enduring due to his unusual immunity to the effects of an unknown element causing rapid aging on the planet Gamma Hydra IV. These included a prcedure involving a needle, which he was assured wouldn't hurt. (TOS: "The Deadly Years")
In 2268, Doctor Leonard McCoy expressed the helplessness he felt while trying to figure out how to reattach Spock's nervous system to his brain, saying he was "threading a needle with a sledgehammer". (TOS: "Spock's Brain")