October is an ideal time to visit Italy. The heat of the summer sun still lingers in the air, and you can explore the countryside without the summer crowds. The water is still warm from the summer sun along the coast, so you can enjoy swimming in the sea by boat or on the beach. It's usually still warm enough to go to the beach, especially in southern Italy.
Sicilians go to the beach until November, if the weather is good. In Northern Italy, you might get lucky and be able to enjoy the beach early in the month, but beach clubs usually close at the end of September. As a result, I suggest that you head south, skip Naples and choose the Amalfi Coast, or take a ferry to Ischia or Anacapri. If you choose the Amalfi Coast, consider driving to fully appreciate the spectacular coastal road and explore the cities between Sorrento, Santa Croce, Positano and Ravello (and even visit the hidden coves of Bagni Della Regina Giovanna and Laurito).
The tourist season will end in October, but the south will still be warm enough to go to the beach. A lightweight waterproof jacket for wet days and colder nights should do the trick. Two other must-see places in Trieste are Piazza Unita d'Italia, probably the most beautiful square in Italy that opens up to the Adriatic Sea, and Miramare Castle, in an impressive location right on the coast. If I had to choose a beach option, I would rather visit the stunning Taormina, in Sicily (by train), than any other option in October.
Another place where you'll find stunning beaches is the western coast of Sicily. La Scala dei Turchi, near Agrigento, is impressive and it's brutally hot in the middle of summer, so October is ideal.