You will pre-clear US customs in Toronto, but that does not exempt you from needing a transit visa. There is a Transit Without Visa program that does not apply to you because it is only available to citizens of Indonesia, Philippines, Thailand, and Taiwan. There is also a China Transit Program that is available only to those holding a passport from the People's Republic of China.
As an Indian Citizen, you can find out about your visa requirements using the visa tool. It will lead you to a page describing transit visas, which describes how you can apply online or with a paper application. The next page says that if you choose to apply with a paper application, you must
Select the country/territory you will be applying from to find out where to submit your application. You can choose your country of nationality or the country/territory where you have been legally admitted.
Therefore, if you choose to submit a paper application, you can apply in Delhi.
Transit visas are free of charge, but if you submit a paper application, you will have to do that through a third-party service provider, which will charge a processing fee.