Production of insect-pollinated crops typically relies on both pesticide use and pollination, leading to a potential conflict between these two inputs. In this paper we combine ecological modelling with economic analysis to investigate the effects of pesticide use on wild and commercial bees, whilst allowing farmers to partly offset the negative effects of pesticides on bee populations by creating more on-farm bee habitat. Farmers have incentives to invest in creating wild bee habitat to increase pollination inputs. However, the optimal allocation of on-farm habitat strongly depends on the negative effects of pesticides, with a threshold-like behaviour at a critical level of the impairment. When this threshold is crossed, the population of wild bees becomes locally extinct and their availability to pollinate breaks down. We also show that availability of commercial bees masks the decrease in pollination services which would otherwise incentivise farmers to conserve the wild pollinator population, therefore indirectly leading to local wild bee extinction. The paper demonstrates the importance of combining ecological modelling with economics to study sustainability in the provision of ecosystem services in agro-ecosystems.