No it's not necessary. However most of the embassies are located in the capital of almost all of the countries. The reason for embassies to be in capital is because of most of the work related to embassy having dependency on host country government. Any interaction between two countries is conveyed through the embassy.