BioWare has put together a blog post detailing how you can get your hands on Treek the Ewok companion in Star Wars: The Old Republic.
There are two options: the cash shop or in-game credits. For the former, obtaining your Ewok companion is as easy as forking over 2100 Cartel Coins and obtaining a Mercenary Contract quest starter item from the Cartel Market. You'll need to be level 10 to finish the quest and claim your reward.
If you prefer to avoid cash shops, you can still obtain the Mercenary Contract via the astromech Legacy Vendor located on your faction's fleet. You'll need a Legacy level of 40 and a million credits. There's a third option, too, and that is buying the contract from another player via the global auction house. There's a bit more info on the process at the official SWTOR website.