Tests are crucial to know about the number of people who have fallen ill with COVID-19 and to understand in real-time whether the dynamics of the pandemic is accelerating or decelerating. But tests are a scarce resource in many countries. The key but still open question is thus how to allocate tests across sub-national levels. We provide a data-driven and operational criterion to allocate tests efficiently across regions or provinces, with the view to maximize detection of people who have been infected. We apply our criterion to Italian regions and compute the shares of tests that should go to each region, which are shown to differ significantly from the actual distribution