Will the security clearance and immigration take place at the Phoenix Airport? Or will it take place at the Santa Barbara Airport?
At the first USA airport you will do immigration, collect your luggage, take it through customs and drop it off again then go through security.
Will 2-hour layover at Phoenix airport be enough? If not what is the recommended layover time?
That should be enough but check the CBP Airport Wait Times page to make sure. I presume you are on a single ticket (on BA/AA, most likely).
If you are on two tickets, my rule of thumb for transatlantic unprotected connections is to calculate with being on the next LHR-PHX flight I can catch. This often means booking a hotel for a night at the layover airport (PHX in this case) and taking the flight the next day. Either that or be ready to book a potentially expensive last minute ticket. This is just how I operate, others might find different levels risk acceptable. It also depends on how much of a rush you are in. All in all, doing two hours with a unprotected connection is only recommended for those cool as a cucumber people who are absolutely not stressed by missing a flight. Otherwise you will spend the entire DEL-LHR-PHX worrying about making your last leg... Again, if you have a single ticket then no worries, if you miss your flight because one of the incoming legs were late, then fixing the situation and getting you to the destination (and getting a hotel potentially) is totally on the airline.