Online: apply at ivd.gib.gov.tr — works for many nationalities and is the fastest option if it's available for your passport.
In person: visit any local tax office (Vergi Dairesi) with your passport — no appointment needed in most districts.
Either way, it's completely free — there is no official fee for the tax number itself.
Your passport (original, not just a copy). A Turkish address helps but isn't always required for the basic number — ask at your local office if you don't have one yet. No Turkish language needed for the in-person route — staff are used to processing foreigners' applications.
A Turkish bank account, your residence permit (Ikamet) application, a local phone contract and many utility connections, company formation if you're setting up a Turkish LTD, and correctly claiming the 0% foreign-income rule under Law No. 7582.
Waiting until you need it for something else — get it in your first day or two instead. Assuming it's the same as your residence permit (Ikamet) application — it isn't, and you'll likely need it before you can even book your residence permit (Ikamet) appointment. And don't lose the number — save it somewhere permanent the moment you get it.