Though the question may be closed as a duplicate, here's an answer that shows how to calculate periods using Kepler's $\color{blue}{\text{3rd}}$ law but with all the constants and units explained.
Here's the equation from Wikipedia's Orbital_period; Small body orbiting a central body. The idea here is that the the size difference is so big that we can assume the central body doesn't move. In reality there is always at least a tiny motion. The Sun-Earth system rotates around a point about 450 kilometers from the Center of the Sun, and outer planets (especially Jupiter and Neptune) move the Sun so much that the center of mass is sometimes completely outside the Sun!
$$T = 2 \pi \sqrt{\frac{a^3}{GM}}$$
Which is Kepler's $\color{blue}{\text{3rd}}$ law:
$$\frac{T^2}{a^3} = \frac{4 \pi^2 }{GM}$$
What are the units?
While it is convenient to use AU and years, as you've found out that only works for orbits around the Sun. The reason is in that case you're really simplifying the equation to a ratio; period divided by another period around the same body, and semimajor axis divided by the semimajor axis of that same other body.
For general calculations I recommend you use meters, seconds and kilograms. You can use any set of units, but you have to be careful that everything is in the same units.
What is $GM$?
It's the gravitational constant $G$ times the mass $M$ of the central body. You can look them up separately, but it turns out that you can find $G$ times $M$ listed as the standard gravitational parameter. These are more accurate than multiplying $G$ times $M$ because each one alone is known to much less accuracy. That's because we can't (easily) measure the mass of a planet by comparing to a standard kilogram. Instead we look at periods and distances of orbits and determine the product $GM$ together.
Here are a few of the numbers from the Wikipedia article, I've rounded them to three decimal places. You can see more decimal places and discussion in the question Where to find the best values for standard gravitational parameters of solar system bodies?.
body GM (m^3/s^2)
------- ------------
Sun 1.327E+20
Earth 3.986E+14
Moon 4.905E+12
Jupiter 1.267E+17
So to get the period of the Earth around the Sun:
$$T = 2 \pi \sqrt{\frac{(\text{1.496E+11})^3}{\text{1.327E+20}}} = \text{3.156E+07 sec} = \text{1 years.}$$
To get the period of Europa around Jupiter:
$$T = 2 \pi \sqrt{\frac{(\text{6.709E+08})^3}{\text{1.267E+17}}} = \text{3.067E+05 sec} = \text{3.550 days.}$$
Wikipedia gives 3.551 days, which is the same considering we're only using three decimal places here. If you take advantage of using $GM$ instead of multiplying $G$ times $M$ and use many more decimal places, you should get agreement to the known periods to many more decimal places as well.
But why don't I get the right period for the Moon?
The Moon's mass is more than 1% that of Earth, so the approximation treating the central body as not moving doesn't work.